> ## Documentation Index
> Fetch the complete documentation index at: https://neo.tvk.company/llms.txt
> Use this file to discover all available pages before exploring further.

# Sidebar Button

> A specialized button designed for integrating perfectly into sidebar navigation with support for collapsing states.

<Warning>
  This widget is specifically designed for use within the [NeoSidebarLayout](../../layouts/sidebar) and should not be used outside of that context.
</Warning>

## Examples

<Tabs>
  <Tab title="States">
    <Frame caption="Different button states for sidebar navigation.">
      <img src="https://mintcdn.com/tvk/xOcwrKRVA4J0vbxn/images/widgets/buttons/sidebar-button/sidebar_button_states_light.png?fit=max&auto=format&n=xOcwrKRVA4J0vbxn&q=85&s=8e6493e674406d837a3cb51908a137cb" alt="Sidebar button states example" noZoom className="block dark:hidden" width="1536" height="384" data-path="images/widgets/buttons/sidebar-button/sidebar_button_states_light.png" />

      <img src="https://mintcdn.com/tvk/xOcwrKRVA4J0vbxn/images/widgets/buttons/sidebar-button/sidebar_button_states_dark.png?fit=max&auto=format&n=xOcwrKRVA4J0vbxn&q=85&s=1410c66e9904a35fea731e2917093a64" alt="Sidebar button states example" noZoom className="hidden dark:block" width="1536" height="384" data-path="images/widgets/buttons/sidebar-button/sidebar_button_states_dark.png" />
    </Frame>

    <CodeGroup>
      ```dart Active State lines theme={null}
      NeoSidebarButton(
        label: "Dashboard",
        icon: PhosphorIcons.squaresFour,
        isActive: true,
        onPressed: () {},
      ),
      ```

      ```dart Default State lines theme={null}
      NeoSidebarButton(
        label: "Products",
        icon: PhosphorIcons.tag,
        onPressed: () {},
      ),
      ```
    </CodeGroup>
  </Tab>

  <Tab title="Badges">
    <Frame caption="Badge functionality for sidebar navigation.">
      <img src="https://mintcdn.com/tvk/xOcwrKRVA4J0vbxn/images/widgets/buttons/sidebar-button/sidebar_button_badges_light.png?fit=max&auto=format&n=xOcwrKRVA4J0vbxn&q=85&s=8695a4e9c8fceacaa661d4339410a7c4" alt="Sidebar button badge example" noZoom className="block dark:hidden" width="1536" height="384" data-path="images/widgets/buttons/sidebar-button/sidebar_button_badges_light.png" />

      <img src="https://mintcdn.com/tvk/xOcwrKRVA4J0vbxn/images/widgets/buttons/sidebar-button/sidebar_button_badges_dark.png?fit=max&auto=format&n=xOcwrKRVA4J0vbxn&q=85&s=3c01728d78b39a4b3f1bc2fc048334e6" alt="Sidebar button badge example" noZoom className="hidden dark:block" width="1536" height="384" data-path="images/widgets/buttons/sidebar-button/sidebar_button_badges_dark.png" />
    </Frame>

    <CodeGroup>
      ```dart Notification Badge lines theme={null}
      NeoSidebarButton(
        label: "Orders",
        icon: PhosphorIcons.receipt,
        badgeText: "138",
        badgeColor: theme.colors.fgDanger,
        isActive: true,
        onPressed: () {},
      ),
      ```

      ```dart New Feature Badge lines theme={null}
      NeoSidebarButton(
        label: "Reports",
        icon: PhosphorIcons.trendUp,
        badgeText: "NEW",
        badgeColor: theme.colors.fgSuccess,
        onPressed: () {},
      ),
      ```

      ```dart Beta Badge lines theme={null}
      NeoSidebarButton(
        label: "Devices",
        icon: PhosphorIcons.devices,
        badgeText: "BETA",
        onPressed: () {},
      ),
      ```
    </CodeGroup>
  </Tab>

  <Tab title="Collapsed Sidebar">
    <Note>When the sidebar is collapsed, label is hidden and badges transform into indicator dots. Tooltips automatically appear on <Tooltip tip="Long press on mobile">hover</Tooltip> to show the button's purpose.</Note>

    <Frame caption="Behavior when sidebar is collapsed.">
      <img src="https://mintcdn.com/tvk/xOcwrKRVA4J0vbxn/images/widgets/buttons/sidebar-button/sidebar_button_collapsed_light.png?fit=max&auto=format&n=xOcwrKRVA4J0vbxn&q=85&s=db4fbf0d39c17b140607c43bb08019b2" alt="Collapsed sidebar button example" noZoom className="block dark:hidden" width="1536" height="384" data-path="images/widgets/buttons/sidebar-button/sidebar_button_collapsed_light.png" />

      <img src="https://mintcdn.com/tvk/xOcwrKRVA4J0vbxn/images/widgets/buttons/sidebar-button/sidebar_button_collapsed_dark.png?fit=max&auto=format&n=xOcwrKRVA4J0vbxn&q=85&s=797e86bdc33382ec83677f5ac397887a" alt="Collapsed sidebar button example" noZoom className="hidden dark:block" width="1536" height="384" data-path="images/widgets/buttons/sidebar-button/sidebar_button_collapsed_dark.png" />
    </Frame>

    <CodeGroup>
      ```dart Collapsed lines theme={null}
      NeoSidebarButton(
        label: "Orders",
        icon: PhosphorIcons.receipt,
        badgeText: "138",
        badgeColor: theme.colors.fgDanger,
        isActive: true,
        onPressed: () {},
      ),
      ```
    </CodeGroup>
  </Tab>
</Tabs>

## Properties

### Required

<ParamField path="label" type="String" required>
  The text label displayed on the button. Also used as tooltip text when sidebar is collapsed.
</ParamField>

<ParamField path="onPressed" type="VoidCallback" required>
  The callback function triggered when the button is pressed.
</ParamField>

### Content

<ParamField path="icon" type="PhosphorIconData Function(PhosphorIconsStyle)">
  The icon to display on the button. Use `PhosphorIcons.yourIconName`. The widget automatically changes the icon style based on the active state.
</ParamField>

<ParamField path="badgeText" type="String">
  When provided, a badge will be displayed on the button. Transforms into an indicator dot when sidebar is collapsed.
</ParamField>

<ParamField path="badgeColor" type="Color">
  The color of the badge.
</ParamField>

<ParamField path="hasCaret" type="bool" default="false">
  <Icon icon="flask" /> Whether to show a caret icon at the end of the button. Useful for indicating expandable sections. Hidden when sidebar is collapsed.
  <Danger>This feature is in alpha and may change. Behavior can be unpredictable.</Danger>
</ParamField>

### State

<ParamField path="isActive" type="bool" default="false">
  Whether the button is in an active/selected state. Active buttons have enhanced styling with duotone icons and branded colors.
</ParamField>

## Best Practices

* Combine with [`NeoHaptics`](/utilities/haptics) in the `onPressed` callback for enhanced user experience on supported devices.
* **Badge Usage**: Use badges for:
  * Notification counts (e.g., "3", "12")
  * Status indicators (e.g., "NEW", "BETA")
  * Alert symbols (e.g., "!")

## Integration Notes

* Designed to work seamlessly with the [NeoSidebarLayout](../../layouts/sidebar) and automatically responds to sidebar state changes.
* Tooltips automatically appear on <Tooltip tip="Long press on mobile">hover</Tooltip> when sidebar is collapsed.
* Badge positioning adapts intelligently based on sidebar state.
