Skip to main content
NetScriptdocs Search docs ⌘K v0.0.9
Browse documentation

Button

Generic action primitive using semantic theme classes.

All components · Theme builder · Implementation source

Live preview

Open live button preview

Install

Shell
netscript ui:add button

Usage and examples

The preview runs this JSX with the installed components. Import any composed primitives from your UI directory.

TypeScript
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.

OwnerPropTypeOptionalDescription
SharedButtonPropsdata-partstringYes
SharedButtonPropsdata-scopestringYes
SharedButtonPropsdata-sizeButtonSizeYes
SharedButtonPropschildrenRenderableNo
SharedButtonPropsvariantButtonVariantYes
SharedButtonPropssizeButtonSizeYes
SharedButtonPropsdisabledbooleanYes
SharedButtonPropsloadingbooleanYes
SharedButtonPropsclassstringYes
SharedButtonPropsiconRenderableYes
SharedButtonPropsiconPosition"left" | "right"Yes
ButtonAsButtonPropstypeButtonElementTypeYes
ButtonAsButtonPropshrefneverYes
ButtonAsButtonPropsclientNavneverYes
ButtonAsLinkPropstype"link"No
ButtonAsLinkPropshrefstringNo
ButtonAsLinkPropsclientNavbooleanYes
TypeScript
type ButtonVariant = "primary" | "secondary" | "outline" | "ghost" | "destructive"
type ButtonSize = "sm" | "md" | "lg" | "icon"
type ButtonElementType = "button" | "submit" | "reset"

Keyboard

KeyAction
EnterActivate
SpaceActivate 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.

Search all documentation

Type a term to search the documentation.