Button
Generic action primitive using semantic theme classes.
All components · Theme builder · Implementation source
Live preview
Install
netscript ui:add buttonUsage and examples
The preview runs this JSX with the installed components. Import any composed primitives from your UI directory.
import { useState } from 'preact/hooks';
import { Button } from '@app/components/ui/button.tsx';
export function Example() {
const [value, setValue] = useState('standard');
const [open, setOpen] = useState(false);
const [notice, report] = useState('');
return (<><div><div class="demo-row"><Button onClick={() => report("Changes saved")}>Save changes</Button><Button variant="outline">Cancel</Button><Button disabled>Disabled</Button></div></div><p role="status">{notice}</p></>);
}Props
Generated from native deno doc --json --private over the shipped implementation. Compound component props retain their owning interface; native attributes pass through where declared.
| Owner | Prop | Type | Optional | Description |
|---|---|---|---|---|
SharedButtonProps | data-part | string | Yes | |
SharedButtonProps | data-scope | string | Yes | |
SharedButtonProps | data-size | ButtonSize | Yes | |
SharedButtonProps | children | Renderable | No | |
SharedButtonProps | variant | ButtonVariant | Yes | |
SharedButtonProps | size | ButtonSize | Yes | |
SharedButtonProps | disabled | boolean | Yes | |
SharedButtonProps | loading | boolean | Yes | |
SharedButtonProps | class | string | Yes | |
SharedButtonProps | icon | Renderable | Yes | |
SharedButtonProps | iconPosition | "left" | "right" | Yes | |
ButtonAsButtonProps | type | ButtonElementType | Yes | |
ButtonAsButtonProps | href | never | Yes | |
ButtonAsButtonProps | clientNav | never | Yes | |
ButtonAsLinkProps | type | "link" | No | |
ButtonAsLinkProps | href | string | No | |
ButtonAsLinkProps | clientNav | boolean | Yes |
type ButtonVariant = "primary" | "secondary" | "outline" | "ghost" | "destructive"
type ButtonSize = "sm" | "md" | "lg" | "icon"
type ButtonElementType = "button" | "submit" | "reset"Keyboard
| Key | Action |
|---|---|
Enter | Activate |
Space | Activate button; links use native Enter |
Tokens
Semantic contract roles: border/default, border/hover, border/width, destructive/default, destructive/fg, destructive/hover, primary/default, primary/fg, primary/hover, radius/control, secondary/border, secondary/default, secondary/fg, text/fg, text/muted.
CSS custom properties referenced directly: --ns-border, --ns-border-hover, --ns-border-strong, --ns-border-width, --ns-component-button-height, --ns-component-button-radius, --ns-control-gap, --ns-control-height, --ns-control-height-lg, --ns-control-height-sm, --ns-control-padding-x, --ns-control-padding-x-sm, --ns-destructive, --ns-destructive-fg, --ns-destructive-hover, --ns-fg, --ns-focus-ring-offset, --ns-focus-ring-width, --ns-font-label, --ns-font-sans, --ns-gray-12, --ns-leading-strong, --ns-motion-duration-normal, --ns-motion-easing-normal, --ns-muted-fg, --ns-primary, --ns-primary-fg, --ns-primary-hover, --ns-primary-stroke, --ns-radius-control, --ns-radius-lg, --ns-radius-sm, --ns-red-6, --ns-ring, --ns-secondary, --ns-secondary-border, --ns-secondary-fg, --ns-secondary-subtle, --ns-space-1-5, --ns-space-2, --ns-space-3, --ns-space-4, --ns-space-6, --ns-state-disabled-opacity, --ns-state-hover-opacity, --ns-state-pressed-opacity, --ns-text-base, --ns-text-label, --ns-text-small, --ns-text-strong, --ns-text-xs, --ns-tracking-strong, --ns-weight-label, --ns-weight-strong.
Contract and compatibility
Accessibility pattern: WAI-ARIA guidance
- Native DOM attributes pass through where the implementation accepts them.
Design contract values marked planned are not implementation props. The props above describe what ships today.