Control Styles

Shared styles for native buttons and fields, to use on your own elements.

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/controls

Usage

import { button, field } from "./ui/uicontext/components/Controls.ts"import { sx } from "./ui/uicontext/components/Sx.ts"
export const NameInput = <M>(h: Html.H<M>) => h.input.attrs({ "aria-label": "Name", ...sx(field.input) })export const SaveButton = <M>(h: Html.H<M>) => h.button.attrs({ type: "submit", ...sx(button.base, button.primary) }).children("Save")

API reference

Options

Field options
NameTypeDescription
labelrequiredstringThe label's text.
childrenrequiredView.ChildrenThe control it labels, such as an input with field.input; clicking the label focuses it.

Accessibility

  • These are styles for native elements, so buttons, inputs and selects keep the browser's keyboard, form and screen reader behavior.
  • Each control shows a focus ring on keyboard focus only, and Field wraps its control in a <label>, so the label names it and a click on it focuses it.

Source