ToggleButton

View on Github

ToggleButton allows users to toggle a selection on or off, for example switching between two states or modes.

Import

import { ToggleButton } from '@contentful/f36-components';
// or
import { ToggleButton } from '@contentful/f36-button';

Examples

Basic

Example of simple usage:

States

Example of active and disabled toggle buttons:

Grouped

You can group several ToggleButtons using ButtonGroup component.

Props (API reference)

  • Name

    aria-label

    Description

    Aria label is required when using icon only

    string
  • Name

    children

    ReactNode
  • Name

    className

    Description

    CSS class to be appended to the root element

    string
  • Name

    icon

    Description

    Expects any of the icon components

    ReactElement<any, string | JSXElementConstructor<any>>
  • Name

    isActive

    Description

    Applies active styles

    false
    true
  • Name

    isDisabled

    Description

    Disabled interaction and applies disabled styles

    false
    true
  • Name

    onToggle

    Description

    Function triggered when the toggle button is clicked.

    () => void
  • Name

    size

    Description

    Determines size variation of Button component

    "small"
    "medium"
    "large"
  • Name

    testId

    Description

    A [data-test-id] attribute used for testing purposes

    string