Button
A pressable control for actions, with consistent visual variants and states.
ButtonView sourceExample
The preview is interactive. The code below it is the docs demo source; demo-only layout classes can be omitted in application code.
import { Cell } from "retend";
import { Button } from "innate-ui";
import { Icon } from "@/docs/icons/Icon";
import classes from "../docs.module.css";
function PlusIcon() {
return <Icon name="plus" />;
}
export function ButtonDemo() {
const created = Cell.source(false);
const label = Cell.derived(() => (created.get() ? "Create another project" : "Create project"));
const createProject = () => created.set(true);
return (
<div class={classes.buttonStack}>
<Button onClick={createProject}>
<Button.Start>
<PlusIcon />
</Button.Start>
{label}
</Button>
<Button variant="primary" onClick={createProject}>
<Button.Start>
<PlusIcon />
</Button.Start>
{label}
</Button>
<Button loading>Creating project</Button>
</div>
);
}API reference
This table is generated from Innate UI's exported TypeScript declarations and JSDoc. Native element attributes inherited by a prop type are not repeated here.
ButtonProps
| Prop | Type | Default |
|---|---|---|
childrenButton label or content. | JSX.Children | — |
variantVisual treatment of the button. | JSX.ValueOrCell<ButtonVariant> | "secondary" |
sizeButton size. | JSX.ValueOrCell<ButtonSize> | "medium" |
disabledWhether the button is disabled. | JSX.ValueOrCell<boolean> | false |
loadingShows the loading state and disables interaction. | JSX.ValueOrCell<boolean> | false |
onClickClick handler. | EventHandlerProp<HTMLButtonElement, MouseEvent> | — |
onPointerEnterPointer-enter handler. | EventHandlerProp<HTMLButtonElement, PointerEvent> | — |
onPointerLeavePointer-leave handler. | EventHandlerProp<HTMLButtonElement, PointerEvent> | — |
onPointerMovePointer-move handler. | EventHandlerProp<HTMLButtonElement, PointerEvent> | — |
onFocusFocus handler. | EventHandlerProp<HTMLButtonElement, FocusEvent> | — |
onBlurBlur handler. | EventHandlerProp<HTMLButtonElement, FocusEvent> | — |
onKeyDownKey-down handler. | EventHandlerProp<HTMLButtonElement, KeyboardEvent> | — |