Sidebar
Display vertical navigation options aside the main content
Use the Sidebar
component to provide additional navigation options and content to your users in a vertical layout next to your main content. Use the Sidebar
component along with a Sheet
component to create toggleable sidebars.
The Sidebar
component expects a single groups
prop that specifies the group of links. Each group must have an items
property that specifies the link in the format of objects with a name
and href
property.
Groups
To create distinct groups, specify a title
property along with the items
property for your groups:
Badges
Sidebar items can be created with extra text to make them highlighted or provide additional context. Use the badge
property on an item to specify additional text, and the badgeTheme
property to change the style of the badge. The badgeTheme
property can take the values of button themes:
By default, badges in sidebars will be created with the success theme.
Icons
Icons can also be assigned to sidebar items. To add an icon to a sidebar item, specify the icon
property:
The icon can be an imported SVG string. You can import icons from webcoreui/icons
. For Astro components, you can also reference the icon type. For available icons in Webcore, see the documentation of the Icon component.
Extra Content
If you need to display extra items in your sidebar, you can pass your elements as the children to the component:
See the documentation of the Alert
component to see how to use it.
Toggleable Sidebar
The Sidebar
component can be combined with the Sheet
component to create toggleable sidebars:
Visit the documentation of the Sheet
component to learn more about how to work with sheets in Webcore.
API
Prop | Purpose |
---|---|
groups | Sets the item groups for the sidebar. |
groups.title | Sets the title of the item group. |
groups.items.name | Sets the name of the anchor. |
groups.items.href | Sets the link of the anchor. |
groups.items.target | Sets the target of the anchor. |
groups.items.active | Sets the anchor as active. Use for the current page. |
groups.items.icon | Sets an icon in front of the anchor's name. |
groups.items.badge | Sets additional text after the anchor. |
groups.items.badgeTheme | Sets the theme of the additional text. |
className | Pass additional CSS classes for the sidebar. |
Request improvement for this page