Page and layout

Sidebar

Navigation down the left on a computer, a drawer on a phone.

openvibe-shared/kitJSON

Build it

kit.withSidebar({ sidebar: kit.sidebar({ id: 'kit-demo-side', label: 'Rooms', nav: [{ href: '/kit/sidebar', label: 'Night owls', icon: 'chat', active: true }, { href: '/kit/sidebar', label: 'Robot arms', icon: 'chat' }, { href: '/kit/sidebar', label: 'Surf crew', icon: 'chat' }] }), body: kit.empty({ title: 'Night owls', text: 'The room opens here.' }) })

Props

id
string?
nav
list?
find
any?
foot
string?
label
string?
action
any?
sections
list?

Anatomy

  • panel272 px wide on a computer; a drawer of up to 320 px on a phone; background color.bg.raised; line color.line.base
  • actionthe one thing to start: New chat, Go live, New post; minHeight size.tap; radius radius.md; color color.text.primary; icon color.accent.base
  • linkthe page you are on: color.accent.base icon on a tint of it, color.text.primary; minHeight size.tap; radius radius.md; color color.text.muted; icon size.icon
  • countbackground color.accent.strong; size type.size.caption; weight type.weight.heavy; radius radius.pill
  • section headinguppercase; color color.text.muted; size type.size.caption; weight type.weight.heavy
  • itemone line, a mark before it and a time or a dot after it; color color.text.primary; size type.size.body; hover color.bg.hover

Behaviour and access

Keyboard
Keeps the focused control in view
Outside tap
Leaves it open
Scroll
Locks the page while open
Reduced motion
Remove movement; keep the state change.
Name
its label (the product)
Target
rows 38 px, 44 px with their gap on touch
Focus
Tab down the rows; Enter opens; Escape closes the drawer and focus returns

States

  • default
  • current
  • focused
  • open

Tokens

  • color.bg.raised
  • color.line.base
  • size.tap
  • radius.md
  • color.text.primary
  • color.accent.base
  • color.text.muted
  • size.icon
  • color.accent.strong
  • type.size.caption
  • type.weight.heavy
  • radius.pill
  • type.size.body
  • color.bg.hover

Android · Jetpack Compose

NavigationDrawer

@Composable fun OvSidebar(items: List<Pair<String, ImageVector>>, current: Int, onPick: (Int) -> Unit, drawer: DrawerState, content: @Composable () -> Unit) { ModalNavigationDrawer(drawerState = drawer, drawerContent = { ModalDrawerSheet(Modifier.widthIn(max = 320.dp)) { Column(Modifier.padding(OvScale.SpaceMd)) { items.forEachIndexed { i, (label, icon) -> NavigationDrawerItem(label = { Text(label) }, icon = { Icon(icon, null, Modifier.size(OvScale.SizeIcon)) }, selected = i == current, onClick = { onPick(i) }, shape = RoundedCornerShape(OvScale.RadiusMd), modifier = Modifier.heightIn(min = OvScale.SizeTap)) } } } }, content = content) }

iOS · SwiftUI

struct OvSidebar<Detail: View>: View { let items: [(label: String, icon: String)] @Binding var current: Int? @ViewBuilder var detail: () -> Detail var body: some View { NavigationSplitView { List(selection: $current) { ForEach(items.indices, id: \.self) { i in Label(items[i].label, systemImage: items[i].icon).frame(minHeight: OvScale.sizeTap).tag(i) } } .listStyle(.sidebar) } detail: { detail() } } }

Markup

Default

<div class="ovk-with-sidebar"><aside class="ovk-sidebar" id="kit-demo-side" aria-label="Rooms" data-ovk-sidebar><div class="ovk-sidebar-top"><button class="ovk-icon-btn ovk-sidebar-close" type="button" data-ovk-sidebar-close aria-label="Close"><svg class="ovk-i" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M5.4 5.4l13.2 13.2M18.6 5.4 5.4 18.6"/></svg></button></div><nav class="ovk-sidebar-nav" aria-label="Rooms"><a class="ovk-sidebar-link" href="/kit/sidebar"><svg class="ovk-i" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M4 5h16v11H8l-4 4Z"/></svg><span>Night owls</span></a><a class="ovk-sidebar-link" href="/kit/sidebar"><svg class="ovk-i" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M4 5h16v11H8l-4 4Z"/></svg><span>Robot arms</span></a><a class="ovk-sidebar-link" href="/kit/sidebar"><svg class="ovk-i" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M4 5h16v11H8l-4 4Z"/></svg><span>Surf crew</span></a></nav></aside><div class="ovk-sidebar-scrim" data-ovk-sidebar-scrim hidden></div><div class="ovk-with-sidebar-main"><div class="ovk-empty"><p class="ovk-empty-title">Night owls</p><p>The room opens here.</p></div></div></div>