A toggle switch button is a graphical user interface (GUI) component that allows the user to switch between two states, such as turning a feature on and off.
Default toggle button example below. Use [checked]="true" to switch the button states.
Add [disabled]="true" to the <base-toggle> if need to disable the button
By default toggle button is with squire knob and border radius. To turn it to circular knob and fully rounded use shape="rounded"
Use attribute size="" to define toggle button size. Toggle button support 3 sizes "sm", "lg" and the default one
Use color="" attribute to define toggle button color. Supported colors are "primary", "success", "danger", "warning" and "accent"
Standalone toggles (no visible text next to the switch) need [ariaLabel] so the native checkbox has an accessible name. Do not set aria-label on the host — Angular binds aria-* attributes to the component element, which never reaches this input.
Run the following command to add this component to your project:
npx base-ui-cli add toggle
For AI agents
Copy a prompt with the registry name, CLI install, and import — or add the Base UI MCP server.
npx -y base-ui-mcp
Base UI provides standalone components. Import the exact elements you want to use into your component.
// Install: npx base-ui-cli add toggle
// Paths are relative to aliases.components (default: src/app/components)
import { ToggleComponent } from './toggle/toggle.component';
@Component({
selector: 'app-your-component',
imports: [
ToggleComponent
],
template: `...`
})
export class YourComponent {} API for toggle — generated from JSDoc in the library source.
| API | Member | Type | Default | Description |
|---|---|---|---|---|
base-toggle | color | ToggleColor | 'primary' | The semantic color variant applied when the toggle is checked. |
base-toggle | size | ToggleSize | 'md' | The physical size of the toggle switch. |
base-toggle | shape | ToggleShape | 'smooth' | The border-radius style of the toggle track and thumb. |
base-toggle | ariaLabel | string | undefined | undefined | Accessible name applied to the underlying checkbox input, for cases where the toggle has no adjacent visible text label (e.g. a standalone switch). Bound as a property (not `aria-label`): Angular applies `aria-*` attribute bindings to the host element, which never reaches this input. |
base-toggle | disabled | boolean | false | Whether the control is disabled (consumer-facing input). |
base-toggle | checked | boolean | false | The current checked/unchecked state. |
Content