Skip to content

Toggle

A pressed-state button using native button behavior. CSS only

Toggle
Copy this markup
<button class="ui-button ui-toggle" type="button" aria-pressed="true">Bold</button>

Install

Styles and registration
import '@timelessui/components/css/tokens.css'
import '@timelessui/components/css/button.css'
import '@timelessui/components/css/toggle.css'

Attributes

Every value below is implemented by the stylesheets this component ships. Boolean attributes are presence-based: author the attribute with no value, or omit it.

AttributeValuesDefaultDescription
data-ui-variantprimary · secondary · outline · ghost · danger · danger-outline · linkprimaryVisual intent, resolved by button.css. Author class="ui-button ui-toggle" so the shared button styling applies.
data-ui-sizesm · md · lgmdControl height, padding, and font size. Resolved by button.css.

State

Native attributes, ARIA, and platform pseudo-classes are authoritative. Style state through the selectors below rather than adding your own state classes.

StateSourceHow to express it
pressedariaAuthor aria-pressed="true" or "false"; never omit it.
disablednativeNative disabled.

Styling

Root identity: ui-toggle. Required stylesheets: tokens.css, button.css, toggle.css.

This component adds no custom properties of its own. Restyle it through the design tokens or your own CSS.

Design tokens this component reads (24)

These are global Atmosphere tokens. Change them once at the theme level rather than per component.

--ui-accent · --ui-accent-soft · --ui-bg-accent · --ui-bg-accent-active · --ui-bg-accent-hover · --ui-bg-control · --ui-bg-control-active · --ui-bg-control-hover · --ui-bg-control-muted · --ui-bg-danger · --ui-bg-danger-active · --ui-bg-danger-hover · --ui-duration-fast · --ui-ease-standard · --ui-fg · --ui-focus · --ui-line · --ui-radius-control · --ui-shadow-control-accent · --ui-shadow-control-active · --ui-shadow-control-danger · --ui-shadow-control-hover · --ui-shadow-outline-control · --ui-space-2

Accessibility

Keep the native elements, roles, and relationships shown in the example. Timeless adds only the state and keyboard coordination the platform does not already provide, and it never supplies your accessible names — those depend on your content.

Before JavaScript runs

This primitive is CSS only. There is nothing to register and nothing to wait for.

More examples

Open Toggle in StoryLite for variants, controls, and manual testing.