suiss/ui
  • Docs
  • Components
  • Patterns
  • Interactions
  • Charts
  • Blocks
  • AI
GitHubCreate
DocsComponentsPatternsInteractionsChartsBlocksAICreate
Patterns19
  • Overview
  • Action Bar
  • Action Menu
  • App Shell
  • Command Palette
  • Confirm
  • Context Actions
  • Date Picker
  • Flyout
  • Modal
  • Navbar
  • Paged List
  • Panel
  • Picker
  • Preview
  • Search Picker
  • Segment Picker
  • Split View
  • Table List
  • Trail

suiss/ui ยท Pattern

Action Bar

A row of menus that renders as a menubar on desktop and a single More actions sheet on mobile.

Action Bar is an open-source pattern from suiss/ui for React, React Native, SwiftUI and Jetpack Compose. The @esuiss/ui CLI copies its source into your project, so you own the code.

import {
  ActionBar,
  ActionBarContent,
  ActionBarItem,
  ActionBarLabel,
  ActionBarMenu,
  ActionBarSeparator,
  ActionBarShortcut,
  ActionBarTrigger,
} from "@/components/patterns/action-bar"

export default function ActionBarDemo() {
  return (
    <div className="min-h-96">
      <ActionBar>
        <ActionBarMenu>

ActionBar groups several ActionBarMenus. On desktop it renders a Menubar, and hovering another trigger while a menu is open switches menus. Below the 48rem breakpoint (useIsMobile), the bar collapses into a ghost icon Button that opens a Drawer with a row per menu; choosing a row opens that menu's items in an AlertSheet.

Use it for toolbar-style command groups, such as File, Edit and View, that need to fit on small screens.

Installation

$ pnpm dlx shadcn@latest add @esuiss/action-bar

Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add patterns action-bar
  1. Install the following dependencies and add the cn helper:
$ pnpm add @base-ui/react @phosphor-icons/react
  1. Add the pieces it builds on: Alert Sheet, Button, Drawer, Menubar, use-mobile.

  2. Copy and paste the following code into your project.

components/patterns/action-bar.tsx
"use client"

import { mergeProps } from "@base-ui/react/merge-props"
import { CaretRightIcon, DotsThreeIcon } from "@phosphor-icons/react"
import * as React from "react"
import {
  AlertSheet,
  AlertSheetAction,
  AlertSheetCancel,
  AlertSheetContent,
  AlertSheetGroup,
  AlertSheetHeader,
  AlertSheetTitle,
} from "@/components/ui/alert-sheet"
import { Button } from "@/components/ui/button"
import {
  1. Update the import paths to match your project setup.

Usage

import {
  ActionBar,
  ActionBarContent,
  ActionBarItem,
  ActionBarLabel,
  ActionBarMenu,
  ActionBarSeparator,
  ActionBarShortcut,
  ActionBarTrigger,
} from "@/components/patterns/action-bar"
<ActionBar>
  <ActionBarMenu>
    <ActionBarTrigger>File</ActionBarTrigger>
    <ActionBarContent>
      <ActionBarItem>
        New tab
        <ActionBarShortcut mod>T</ActionBarShortcut>
      </ActionBarItem>
      <ActionBarSeparator />
      <ActionBarItem>
        Print
        <ActionBarShortcut mod>P</ActionBarShortcut>
      </ActionBarItem>
    </ActionBarContent>
  </ActionBarMenu>
  <ActionBarMenu>
    <ActionBarTrigger>View</ActionBarTrigger>
    <ActionBarContent>
      <ActionBarLabel>Appearance</ActionBarLabel>
      <ActionBarItem>Zoom in</ActionBarItem>
      <ActionBarItem>Zoom out</ActionBarItem>
    </ActionBarContent>
  </ActionBarMenu>
</ActionBar>

Examples

With icons

Places an icon before each item in the Edit menu. Set variant="destructive" on an item, here Delete, to style it as a destructive action.

import {
  ClipboardTextIcon,
  CopyIcon,
  ScissorsIcon,
  TrashIcon,
} from "@phosphor-icons/react"
import {
  ActionBar,
  ActionBarContent,
  ActionBarItem,
  ActionBarLabel,
  ActionBarMenu,
  ActionBarSeparator,
  ActionBarShortcut,
  ActionBarTrigger,
} from "@/components/patterns/action-bar"

By default

Set defaultOpen on the bar and on the File menu to open it on first render. On desktop only the menu's defaultOpen applies.

import {
  ActionBar,
  ActionBarContent,
  ActionBarItem,
  ActionBarLabel,
  ActionBarMenu,
  ActionBarSeparator,
  ActionBarShortcut,
  ActionBarTrigger,
} from "@/components/patterns/action-bar"

export default function ActionBarOpenByDefault() {
  return (
    <div className="min-h-96">
      <ActionBar defaultOpen>
        <ActionBarMenu defaultOpen>

Not dismissible

Set dismissible to false so mobile sheets use an alert dialog that closes only through an action or Cancel, not on an outside press.

import {
  ActionBar,
  ActionBarContent,
  ActionBarItem,
  ActionBarMenu,
  ActionBarSeparator,
  ActionBarShortcut,
  ActionBarTrigger,
} from "@/components/patterns/action-bar"

export default function ActionBarNotDismissible() {
  return (
    <div className="min-h-96">
      <ActionBar dismissible={false}>
        <ActionBarMenu>
          <ActionBarTrigger>File</ActionBarTrigger>

Custom labels

Use moreLabel to rename the mobile More actions button and its drawer title, and cancelLabel to rename the Cancel button of each sheet.

import {
  ActionBar,
  ActionBarContent,
  ActionBarItem,
  ActionBarMenu,
  ActionBarSeparator,
  ActionBarShortcut,
  ActionBarTrigger,
} from "@/components/patterns/action-bar"

export default function ActionBarCustomLabels() {
  return (
    <div className="min-h-96">
      <ActionBar moreLabel="Document actions" cancelLabel="Close">
        <ActionBarMenu>
          <ActionBarTrigger>File</ActionBarTrigger>

Floating

Set floating to inset the mobile More actions drawer from the screen edges with fully rounded corners.

import {
  ActionBar,
  ActionBarContent,
  ActionBarItem,
  ActionBarLabel,
  ActionBarMenu,
  ActionBarSeparator,
  ActionBarShortcut,
  ActionBarTrigger,
} from "@/components/patterns/action-bar"

export default function ActionBarFloating() {
  return (
    <div className="min-h-96">
      <ActionBar floating>
        <ActionBarMenu>

Accessibility

  • On desktop the bar has the menubar role and each trigger and item has the menuitem role.
  • Disabled items expose aria-disabled="true".
  • Escape closes an open menu and returns focus to its trigger.
  • On mobile the More actions button is labelled by moreLabel, and each drawer row has aria-haspopup="dialog".

API Reference

ActionBar

The root that renders a Menubar on desktop and a More actions button with a Drawer on mobile.

PropTypeDefault
openboolean-
defaultOpenbooleanfalse
onOpenChange(open: boolean) => void-
dismissiblebooleantrue
floatingboolean-
moreLabelstring"More actions"
cancelLabelstring"Cancel"

Also accepts the props of React.ComponentProps<"div">.

Each child should be an ActionBarMenu; the bar uses the child index to pair the mobile row with its sheet. open, defaultOpen and onOpenChange control the mobile More actions drawer only and have no effect on desktop.

ActionBarMenu

One menu in the bar; a MenubarMenu on desktop and an AlertSheet on mobile.

PropTypeDefault
openboolean-
defaultOpenboolean-
onOpenChange(open: boolean) => void-
childrenReact.ReactNode-

Put one ActionBarTrigger and one ActionBarContent in each menu. Its own open, defaultOpen and onOpenChange control that menu, on desktop and for the mobile sheet.

ActionBarTrigger

The menu's button; a menubar trigger on desktop and a drawer row with a chevron on mobile.

Also accepts the props of React.ButtonHTMLAttributes<HTMLButtonElement>.

ActionBarContent

The menu's items; a MenubarContent popup on desktop and an AlertSheetContent with a Cancel button on mobile.

Also accepts align, alignOffset, side and sideOffset from MenubarContent, which position the desktop popup, and the props of React.HTMLAttributes<HTMLElement>.

Also accepts align, alignOffset, side and sideOffset from MenubarContent, which position the desktop popup, and className, children, id and aria-label.

ActionBarLabel

A non-interactive heading; a menu label on desktop and the sheet title on mobile.

Also accepts the props of React.HTMLAttributes<HTMLElement>.

Also accepts className, children and id.

ActionBarItem

An actionable entry; a MenubarItem on desktop and an AlertSheetAction on mobile.

PropTypeDefault
variant"default" | "destructive"-
disabledboolean-

Also accepts the props of React.HTMLAttributes<HTMLElement>.

Respond to the item with onAction. Also accepts className, children, id and aria-label.

ActionBarSeparator

A divider between item groups, rendered on desktop only.

Also accepts the props of React.HTMLAttributes<HTMLElement>.

Also accepts className.

ActionBarShortcut

A keyboard shortcut hint aligned to the end of an item, rendered on desktop only.

Also accepts the props of React.ComponentProps<typeof MenubarShortcut>.

Set mod to prefix the platform modifier key. ActionBarSeparator and ActionBarShortcut render nothing on mobile. Each part sets a data-slot, such as action-bar-trigger or action-bar-more, for styling.

Web

Web preview

import {
  ActionBar,
  ActionBarContent,
  ActionBarItem,
  ActionBarLabel,
  ActionBarMenu,
  ActionBarSeparator,
  ActionBarTrigger,
} from "@/components/patterns/action-bar"
import { Text } from "@/components/ui/text"

export default function ActionBarOpenByDefault() {
  return (
    <ActionBar defaultOpen>
      <ActionBarMenu defaultOpen>
        <ActionBarTrigger>File</ActionBarTrigger>
import PhosphorSwift
import SwiftUI

struct ActionBarOpenFileDemo: View {
  @State private var file = true

  var body: some View {
    ActionBar {
      ActionBarFileMenu(isPresented: $file)
      ActionBarEditMenu()
      ActionBarViewMenu()
    }
  }
}

struct ActionBarFileMenu: View {
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import com.adamglin.PhosphorIcons
import com.adamglin.phosphoricons.Regular
import com.adamglin.phosphoricons.regular.ClipboardText
import com.adamglin.phosphoricons.regular.Copy
import com.adamglin.phosphoricons.regular.Scissors
import com.adamglin.phosphoricons.regular.Trash
import com.esuiss.ui.components.MenuItemVariant
import com.esuiss.ui.patterns.ActionBar
import com.esuiss.ui.patterns.ActionBarItem

ActionBar groups several ActionBarMenus, such as File, Edit and View, behind one ghost icon Button. Pressing it opens a Drawer that lists each menu's trigger as a row with a chevron; choosing a row opens that menu's items in an AlertSheet, with a Cancel button appended.

Use it for toolbar-style command groups that need to fit on a phone screen.

Each child of ActionBar should be an ActionBarMenu containing one ActionBarTrigger and one ActionBarContent. The bar renders every child twice, once as a drawer row and once as a sheet, and pairs them by child index.

Installation

$ pnpm dlx shadcn@latest add @esuiss/action-bar

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add patterns action-bar
$ pnpm dlx shadcn@latest add @esuiss/action-bar

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add patterns action-bar --platform swift
$ pnpm dlx shadcn@latest add @esuiss/action-bar

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add patterns action-bar --platform kotlin

The CLI also adds what it builds on: Alert Sheet, Button, Drawer, Icon, Text.

  1. Install the following dependencies:
npx expo install cn phosphor-react-native react-native-svg
  1. Add the pieces it builds on: Alert Sheet, Button, Drawer, Icon, Text.

  2. Copy and paste the following code into components/patterns/action-bar.tsx:

uniwind/components/patterns/action-bar.tsx
import { cn } from "cn"
import { CaretRightIcon, DotsThreeIcon } from "phosphor-react-native"
import * as React from "react"
import { I18nManager, Pressable, View, type ViewProps } from "react-native"
import {
  AlertSheet,
  AlertSheetAction,
  AlertSheetCancel,
  AlertSheetContent,
  AlertSheetGroup,
  AlertSheetHeader,
  AlertSheetTitle,
} from "@/components/ui/alert-sheet"
import { Button } from "@/components/ui/button"
import { Drawer, DrawerContent, DrawerTrigger } from "@/components/ui/drawer"
import { Icon } from "@/components/ui/icon"
  1. Update the import paths to match your project setup.
  1. Install the following dependencies:
npx expo install cn phosphor-react-native react-native-svg
  1. Add the pieces it builds on: Alert Sheet, Button, Drawer, Icon, Text.

  2. Copy and paste the following code into components/patterns/action-bar.tsx:

nativewind/components/patterns/action-bar.tsx
import { cn } from "cn"
import { CaretRightIcon, DotsThreeIcon } from "phosphor-react-native"
import * as React from "react"
import { I18nManager, Pressable, View, type ViewProps } from "react-native"
import {
  AlertSheet,
  AlertSheetAction,
  AlertSheetCancel,
  AlertSheetContent,
  AlertSheetGroup,
  AlertSheetHeader,
  AlertSheetTitle,
} from "@/components/ui/alert-sheet"
import { Button } from "@/components/ui/button"
import { Drawer, DrawerContent, DrawerTrigger } from "@/components/ui/drawer"
import { Icon } from "@/components/ui/icon"
  1. Update the import paths to match your project setup.
  1. Install the following dependencies:
npx expo install phosphor-react-native react-native-svg
  1. Add the pieces it builds on: Alert Sheet, Button, Drawer, Icon, Text.

  2. Copy and paste the following code into components/patterns/action-bar.tsx:

stylesheet/components/patterns/action-bar.tsx
import { CaretRightIcon, DotsThreeIcon } from "phosphor-react-native"
import * as React from "react"
import {
  I18nManager,
  Pressable,
  type StyleProp,
  StyleSheet,
  View,
  type ViewProps,
  type ViewStyle,
} from "react-native"
import {
  AlertSheet,
  AlertSheetAction,
  AlertSheetCancel,
  AlertSheetContent,
  1. Update the import paths to match your project setup.
  1. Target iOS 17 or later.

  2. Add the Swift package to your app:

Package.swift
.package(url: "https://github.com/phosphor-icons/swift", from: "2.1.0")
  1. Copy the theme files every view uses:
swift/Theme/Theme.swift
import CoreText
import SwiftUI
import UIKit

struct RGBA: Sendable {
  let red: CGFloat
  let green: CGFloat
  let blue: CGFloat
  let alpha: CGFloat

  init(_ hex: UInt32, _ alpha: CGFloat = 1) {
    red = CGFloat((hex >> 16) & 0xFF) / 255
    green = CGFloat((hex >> 8) & 0xFF) / 255
    blue = CGFloat(hex & 0xFF) / 255
    self.alpha = alpha
  }
swift/Theme/Tokens.swift
import SwiftUI

public enum EsuissColor {
  public static let background = Color.adaptive(light: .init(0xFFFFFF), dark: .init(0x000000))
  public static let foreground = Color.adaptive(light: .init(0x1D1D1F), dark: .init(0xF5F5F7))
  public static let card = Color.adaptive(light: .init(0xFFFFFF), dark: .init(0x1D1D1F))
  public static let cardForeground = Color.adaptive(light: .init(0x1D1D1F), dark: .init(0xF5F5F7))
  public static let popover = Color.adaptive(light: .init(0xFFFFFF), dark: .init(0x1D1D1F))
  public static let popoverForeground = Color.adaptive(light: .init(0x1D1D1F), dark: .init(0xF5F5F7))
  public static let primary = Color.adaptive(light: .init(0x0071E3), dark: .init(0x0A84FF))
  public static let primaryForeground = Color.adaptive(light: .init(0xFFFFFF), dark: .init(0xFFFFFF))
  public static let secondary = Color.adaptive(light: .init(0x000000, 0.04), dark: .init(0xFFFFFF, 0.1))
  public static let secondaryForeground = Color.adaptive(light: .init(0x1D1D1F), dark: .init(0xF5F5F7))
  public static let muted = Color.adaptive(light: .init(0xF5F5F7), dark: .init(0x161617))
  public static let mutedForeground = Color.adaptive(light: .init(0x6E6E73), dark: .init(0x86868B))
  public static let accent = Color.adaptive(light: .init(0x000000, 0.06), dark: .init(0xFFFFFF, 0.1))
  1. Copy the source and every file it uses:
swift/Patterns/ActionBar.swift
import PhosphorSwift
import SwiftUI

enum ActionBarPart: Sendable {
  case row, sheet, menu
}

struct ActionBarContext {
  var part: ActionBarPart
  var dismissible: Bool
  var cancelLabel: LocalizedStringKey
  var open: (@escaping () -> Void) -> Void
  var present: (AnyView) -> Void
}

extension EnvironmentValues {
swift/Components/AlertSheet.swift
import SwiftUI

extension View {
  public func alertSheet<Content: View>(
    isPresented: Binding<Bool>,
    dismissible: Bool = true,
    @ViewBuilder content: @escaping () -> Content
  ) -> some View {
    modifier(
      CoverPresenter(
        isPresented: isPresented,
        enter: .timingCurve(0.32, 0.72, 0, 1, duration: 0.3),
        exit: .timingCurve(0.32, 0.72, 0, 1, duration: 0.25)
      ) { visible in
        AlertSheetStage(visible: visible, dismissible: dismissible, content: content)
      }
swift/Components/Button.swift
import SwiftUI

public struct VariantButtonStyle: ButtonStyle {
  public enum Variant: CaseIterable, Sendable {
    case `default`, outline, secondary, tinted, ghost, plain, destructive, link
  }

  public enum Size: CaseIterable, Sendable {
    case `default`, xs, sm, lg, xl, form, icon, iconXs, iconSm, iconLg, iconXl

    var height: CGFloat {
      switch self {
      case .xs, .iconXs: Metrics.Height.buttonXs
      case .sm, .iconSm: Metrics.Height.buttonSm
      case .default, .icon: Metrics.Height.button
      case .lg, .iconLg: Metrics.Height.buttonLg
swift/Components/ButtonGroup.swift
import SwiftUI

extension EnvironmentValues {
  @Entry var buttonGroup: Axis? = nil
  @Entry var buttonGroupSize: CGSize = .zero
}

enum ButtonGroupSpace: Hashable {
  case group
}

struct ButtonGroupFrame {
  let bounds: Anchor<CGRect>
  let outlined: Bool
}
swift/Components/Dialog.swift
import SwiftUI

extension View {
  public func dialog<Content: View>(
    isPresented: Binding<Bool>,
    @ViewBuilder content: @escaping () -> Content
  ) -> some View {
    modifier(
      CoverPresenter(isPresented: isPresented) { visible in
        CenteredStage(visible: visible, dismissible: true, content: content)
      }
    )
  }
}

struct CenteredStage<Content: View>: View {
swift/Components/Drawer.swift
import SwiftUI

extension View {
  public func drawer<Content: View>(
    isPresented: Binding<Bool>,
    detents: Set<PresentationDetent>? = nil,
    selection: Binding<PresentationDetent>? = nil,
    onDismiss: (() -> Void)? = nil,
    @ViewBuilder content: @escaping () -> Content
  ) -> some View {
    let binding = isPresented
    return sheet(isPresented: isPresented, onDismiss: onDismiss) {
      DrawerHost(detents: detents, selection: selection, content: content)
        .environment(\.overlayDismiss, OverlayDismiss { binding.wrappedValue = false })
    }
  }
swift/Components/DropdownMenu.swift
import PhosphorSwift
import SwiftUI

enum MenuPresentation: Sendable {
  case system, popup
}

extension EnvironmentValues {
  @Entry var menuPresentation: MenuPresentation = .system
  @Entry var menuRadio = MenuRadioContext()
}

struct MenuRadioContext: @unchecked Sendable {
  var selected: AnyHashable?
  var select: @MainActor @Sendable (AnyHashable) -> Void = { _ in }
}
swift/Components/Field.swift
import SwiftUI

extension EnvironmentValues {
  @Entry public var isInvalid = false
  @Entry var fieldInset = false
  @Entry var fieldSize = FieldSize.default
  @Entry var fieldGroupInset = false
  @Entry var fieldSetInset = false
}

extension View {
  public func invalid(_ isInvalid: Bool = true) -> some View {
    environment(\.isInvalid, isInvalid)
  }
}
swift/Components/Input.swift
import SwiftUI

public struct InputStyle: TextFieldStyle {
  public enum Size: CaseIterable, Sendable {
    case `default`, md, sm, lg

    var height: CGFloat {
      switch self {
      case .default: Metrics.Height.input
      case .md: 36
      case .sm: 32
      case .lg: InputMetrics.largeHeight
      }
    }

    var horizontalPadding: CGFloat {
swift/Components/Overlay.swift
import Observation
import PhosphorSwift
import SwiftUI

public enum PopupAlignment: Sendable, CaseIterable {
  case start, center, end
}

struct OverlayDismiss: Sendable {
  let action: @MainActor @Sendable () -> Void

  @MainActor func callAsFunction() {
    action()
  }
}
swift/Components/Select.swift
import PhosphorSwift
import SwiftUI

struct SelectContext: @unchecked Sendable {
  var selected: AnyHashable?
  var registering = false
  var select: @MainActor @Sendable (AnyHashable) -> Void = { _ in }
}

extension EnvironmentValues {
  @Entry var select = SelectContext()
}

struct SelectLabelsKey: PreferenceKey {
  static var defaultValue: [AnyHashable: Text] { [:] }
swift/Components/Separator.swift
import SwiftUI

public struct Separator: View {
  let orientation: Axis

  public init(_ orientation: Axis = .horizontal) {
    self.orientation = orientation
  }

  public var body: some View {
    Rectangle()
      .fill(EsuissColor.border)
      .frame(width: orientation == .vertical ? 1 : nil, height: orientation == .horizontal ? 1 : nil)
      .frame(maxWidth: orientation == .horizontal ? .infinity : nil, maxHeight: orientation == .vertical ? .infinity : nil)
      .accessibilityHidden(true)
  }
swift/Components/Sheet.swift
import SwiftUI

extension View {
  public func sheet<Content: View>(
    isPresented: Binding<Bool>,
    side: Edge,
    @ViewBuilder content: @escaping () -> Content
  ) -> some View {
    modifier(
      CoverPresenter(
        isPresented: isPresented,
        enter: .easeOut(duration: 0.4),
        exit: .easeIn(duration: 0.3)
      ) { visible in
        SideSheetStage(side: side, visible: visible, content: content)
      }
swift/Patterns/ActionList.swift
import SwiftUI

enum ActionListMode: Sendable {
  case sheet, menu
}

extension EnvironmentValues {
  @Entry var actionListMode: ActionListMode = .menu
}

struct ActionSheetBody<Content: View>: View {
  let cancelLabel: LocalizedStringKey
  @ViewBuilder let content: () -> Content

  var body: some View {
    AlertSheetContent {
swift/Patterns/Adaptive.swift
import SwiftUI

extension EnvironmentValues {
  @Entry var patternCompact: Bool? = nil
}

@propertyWrapper
struct CompactLayout: DynamicProperty {
  @Environment(\.patternCompact) private var forced
  @Environment(\.horizontalSizeClass) private var sizeClass

  init() {}

  var wrappedValue: Bool {
    forced ?? (sizeClass != .regular)
  }
  1. Add the files to your app target.
  1. Apply the Compose compiler plugin, enable Compose, set compileSdk to 37 or higher and minSdk to 24 or higher, and add the dependencies:
build.gradle.kts
plugins {
    id("org.jetbrains.kotlin.plugin.compose")
}

android {
    compileSdk = 37
    defaultConfig { minSdk = 24 }
    buildFeatures { compose = true }
}

dependencies {
    implementation(platform("androidx.compose:compose-bom:2026.09.00"))
    implementation("androidx.compose.foundation:foundation")
    implementation("androidx.compose.ui:ui")
    implementation("com.adamglin:phosphor-icon-android:1.0.0")
}
  1. Copy the theme files every view uses:
kotlin/theme/Theme.kt
package com.esuiss.ui.theme

import android.content.res.AssetManager
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.Immutable
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.dropShadow
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.graphics.shadow.Shadow as DropShadow
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.Font
kotlin/theme/Tokens.kt
package com.esuiss.ui.theme

import androidx.compose.runtime.Immutable
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp

@Immutable
data class Colors(
    val background: Color,
    val foreground: Color,
    val card: Color,
    val cardForeground: Color,
    val popover: Color,
    val popoverForeground: Color,
    val primary: Color,
  1. Copy the source and every file it uses:
kotlin/patterns/ActionBar.kt
package com.esuiss.ui.patterns

import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.BasicText
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.LaunchedEffect
kotlin/components/AlertSheet.kt
package com.esuiss.ui.components

import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.core.MutableTransitionState
import androidx.compose.animation.core.tween
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.slideInVertically
import androidx.compose.animation.slideOutVertically
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.collectIsPressedAsState
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
kotlin/components/Button.kt
package com.esuiss.ui.components

import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.collectIsPressedAsState
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.BasicText
kotlin/components/ButtonGroup.kt
package com.esuiss.ui.components

import androidx.compose.foundation.background
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.CornerSize
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.Immutable
kotlin/components/Checkbox.kt
package com.esuiss.ui.components

import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.collectIsPressedAsState
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.selection.triStateToggleable
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
kotlin/components/Content.kt
package com.esuiss.ui.components

import androidx.compose.runtime.compositionLocalOf
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp

val LocalContentStyle = compositionLocalOf { TextStyle.Default }

val LocalContentColor = compositionLocalOf { Color.Unspecified }

val LocalIconSize = compositionLocalOf { 20.dp }
kotlin/components/Drawer.kt
package com.esuiss.ui.components

import androidx.compose.animation.core.CubicBezierEasing
import androidx.compose.animation.core.tween
import androidx.compose.foundation.background
import androidx.compose.foundation.gestures.AnchoredDraggableDefaults
import androidx.compose.foundation.gestures.AnchoredDraggableState
import androidx.compose.foundation.gestures.DraggableAnchors
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.gestures.anchoredDraggable
import androidx.compose.foundation.gestures.animateTo
import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxWithConstraints
import androidx.compose.foundation.layout.Column
kotlin/components/DropdownMenu.kt
package com.esuiss.ui.components

import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.collectIsPressedAsState
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.IntrinsicSize
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
kotlin/components/Field.kt
package com.esuiss.ui.components

import androidx.compose.foundation.background
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.LayoutScopeMarker
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.BasicText
kotlin/components/FormSupport.kt
package com.esuiss.ui.components

import android.provider.Settings
import androidx.compose.animation.core.CubicBezierEasing
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.text.selection.TextSelectionColors
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.drawWithContent
import androidx.compose.ui.geometry.Offset
kotlin/components/Haptics.kt
package com.esuiss.ui.components

import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.remember
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.hapticfeedback.HapticFeedback
import androidx.compose.ui.hapticfeedback.HapticFeedbackType
import androidx.compose.ui.platform.LocalHapticFeedback

val LocalHapticsEnabled = staticCompositionLocalOf { true }

@Composable
fun ProvideHaptics(enabled: Boolean, content: @Composable () -> Unit) {
    CompositionLocalProvider(LocalHapticsEnabled provides enabled, content = content)
}
kotlin/components/Icon.kt
package com.esuiss.ui.components

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.graphics.takeOrElse
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.unit.Dp
import com.esuiss.ui.theme.EsuissTheme

@Composable
fun Icon(
    imageVector: ImageVector,
kotlin/components/Label.kt
package com.esuiss.ui.components

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.text.BasicText
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import com.esuiss.ui.theme.EsuissTheme
import com.esuiss.ui.theme.Typography
kotlin/components/Overlay.kt
package com.esuiss.ui.components

import android.os.Build
import android.view.Window
import android.view.WindowManager
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.AnimatedVisibilityScope
import androidx.compose.animation.EnterExitState
import androidx.compose.animation.core.MutableTransitionState
import androidx.compose.animation.core.animateFloat
import androidx.compose.animation.core.tween
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.scaleIn
import androidx.compose.animation.scaleOut
import androidx.compose.animation.slideIn
kotlin/components/Separator.kt
package com.esuiss.ui.components

import androidx.compose.foundation.background
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.width
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.esuiss.ui.theme.EsuissTheme

@Composable
fun Separator(
kotlin/patterns/ActionList.kt
package com.esuiss.ui.patterns

import androidx.compose.runtime.Composable
import androidx.compose.runtime.Immutable
import androidx.compose.ui.Modifier
import com.esuiss.ui.components.AlertSheet
import com.esuiss.ui.components.AlertSheetActionVariant
import com.esuiss.ui.components.AlertSheetCancel
import com.esuiss.ui.components.AlertSheetGroup
import com.esuiss.ui.components.AlertSheetHeader
import com.esuiss.ui.components.AlertSheetTitle
import com.esuiss.ui.components.MenuItemVariant

@Immutable
internal class SheetMenuState(
    val open: Boolean,
  1. Update the com.esuiss.ui package names to match your project.

Usage

import { ClipboardTextIcon, CopyIcon, ScissorsIcon, TrashIcon } from "phosphor-react-native"
import { ActionBar, ActionBarContent, ActionBarItem, ActionBarLabel, ActionBarMenu, ActionBarSeparator, ActionBarTrigger } from "@/components/patterns/action-bar"
import { Icon } from "@/components/ui/icon"
import { Text } from "@/components/ui/text"

function FileMenu({ defaultOpen }: { defaultOpen?: boolean }) {
  return (
    <ActionBarMenu defaultOpen={defaultOpen}>
      <ActionBarTrigger>File</ActionBarTrigger>
      <ActionBarContent>
        <ActionBarItem>New tab</ActionBarItem>
        <ActionBarItem>New window</ActionBarItem>
        <ActionBarItem disabled>New incognito window</ActionBarItem>
        <ActionBarSeparator />
        <ActionBarItem>Print</ActionBarItem>
      </ActionBarContent>
    </ActionBarMenu>
  )
}

function EditMenu({ withIcons = false }: { withIcons?: boolean }) {
  return (
    <ActionBarMenu>
      <ActionBarTrigger>Edit</ActionBarTrigger>
      <ActionBarContent>
        <ActionBarItem>
          {withIcons ? <Icon as={ScissorsIcon} /> : null}
          <Text>Cut</Text>
        </ActionBarItem>
        <ActionBarItem>
          {withIcons ? <Icon as={CopyIcon} /> : null}
          <Text>Copy</Text>
        </ActionBarItem>
        <ActionBarItem>
          {withIcons ? <Icon as={ClipboardTextIcon} /> : null}
          <Text>Paste</Text>
        </ActionBarItem>
        <ActionBarSeparator />
        <ActionBarItem variant="destructive">
          {withIcons ? <Icon as={TrashIcon} /> : null}
          <Text>Delete</Text>
        </ActionBarItem>
      </ActionBarContent>
    </ActionBarMenu>
  )
}

function ViewMenu() {
  return (
    <ActionBarMenu>
      <ActionBarTrigger>View</ActionBarTrigger>
      <ActionBarContent>
        <ActionBarLabel>Appearance</ActionBarLabel>
        <ActionBarItem>Zoom in</ActionBarItem>
        <ActionBarItem>Zoom out</ActionBarItem>
        <ActionBarItem>Actual size</ActionBarItem>
      </ActionBarContent>
    </ActionBarMenu>
  )
}

export function ActionBarExample() {
  return (
    <ActionBar>
      <FileMenu />
      <EditMenu />
      <ViewMenu />
    </ActionBar>
  )
}
import PhosphorSwift
import SwiftUI

struct ActionBarExample: View {
  var body: some View {
    ActionBarDemo {
      ActionBarFileMenu()
      ActionBarEditMenu()
      ActionBarViewMenu()
    }
  }
}

struct ActionBarDemo<Content: View>: View {
  var dismissible = true
  var moreLabel: LocalizedStringKey = "More actions"
  var cancelLabel: LocalizedStringKey = "Cancel"
  let content: Content

  @State private var open: Bool

  init(
    open: Bool = false,
    dismissible: Bool = true,
    moreLabel: LocalizedStringKey = "More actions",
    cancelLabel: LocalizedStringKey = "Cancel",
    @ViewBuilder content: () -> Content
  ) {
    _open = State(initialValue: open)
    self.dismissible = dismissible
    self.moreLabel = moreLabel
    self.cancelLabel = cancelLabel
    self.content = content()
  }

  var body: some View {
    ActionBar(isPresented: $open, dismissible: dismissible, moreLabel: moreLabel, cancelLabel: cancelLabel) {
      content
    }
  }
}

struct ActionBarFileMenu: View {
  var isPresented: Binding<Bool>?

  var body: some View {
    ActionBarMenu("File", isPresented: isPresented) {
      ActionBarItem("New tab") {}
      ActionBarItem("New window") {}
      ActionBarItem("New incognito window") {}.disabled(true)
      ActionBarSeparator()
      ActionBarItem("Print") {}
    }
  }
}

struct ActionBarEditMenu: View {
  var withIcons = false

  var body: some View {
    ActionBarMenu("Edit") {
      if withIcons {
        ActionBarItem("Cut", icon: Ph.scissors.regular) {}
        ActionBarItem("Copy", icon: Ph.copy.regular) {}
        ActionBarItem("Paste", icon: Ph.clipboardText.regular) {}
        ActionBarSeparator()
        ActionBarItem("Delete", icon: Ph.trash.regular, variant: .destructive) {}
      } else {
        ActionBarItem("Cut") {}
        ActionBarItem("Copy") {}
        ActionBarItem("Paste") {}
        ActionBarSeparator()
        ActionBarItem("Delete", variant: .destructive) {}
      }
    }
  }
}

struct ActionBarViewMenu: View {
  var body: some View {
    ActionBarMenu("View") {
      ActionBarLabel("Appearance")
      ActionBarItem("Zoom in") {}
      ActionBarItem("Zoom out") {}
      ActionBarItem("Actual size") {}
    }
  }
}
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import com.adamglin.PhosphorIcons
import com.adamglin.phosphoricons.Regular
import com.adamglin.phosphoricons.regular.ClipboardText
import com.adamglin.phosphoricons.regular.Copy
import com.adamglin.phosphoricons.regular.Scissors
import com.adamglin.phosphoricons.regular.Trash
import com.esuiss.ui.components.MenuItemVariant
import com.esuiss.ui.patterns.ActionBar
import com.esuiss.ui.patterns.ActionBarItem
import com.esuiss.ui.patterns.ActionBarLabel
import com.esuiss.ui.patterns.ActionBarScope
import com.esuiss.ui.patterns.ActionBarSeparator

@Composable
fun ActionBarDemo(
    defaultOpen: Boolean = false,
    fileOpen: Boolean = false,
    withIcons: Boolean = false,
    view: Boolean = true,
    dismissible: Boolean = true,
    floating: Boolean = false,
    moreLabel: String = "More actions",
    cancelLabel: String = "Cancel",
) {
    var open by rememberSaveable { mutableStateOf(defaultOpen) }
    ActionBar(
        open = open,
        onOpenChange = { open = it },
        modifier = Modifier.fillMaxWidth(),
        dismissible = dismissible,
        floating = floating,
        moreLabel = moreLabel,
        cancelLabel = cancelLabel,
    ) {
        actionBarFileMenu(fileOpen)
        actionBarEditMenu(withIcons)
        if (view) actionBarViewMenu()
    }
}

fun ActionBarScope.actionBarFileMenu(defaultOpen: Boolean) {
    ActionBarMenu(defaultOpen = defaultOpen) {
        ActionBarTrigger("File")
        ActionBarContent {
            ActionBarItem("New tab", onClick = {})
            ActionBarItem("New window", onClick = {})
            ActionBarItem("New incognito window", onClick = {}, enabled = false)
            ActionBarSeparator()
            ActionBarItem("Print", onClick = {})
        }
    }
}

fun ActionBarScope.actionBarEditMenu(withIcons: Boolean) {
    ActionBarMenu {
        ActionBarTrigger("Edit")
        ActionBarContent {
            ActionBarItem("Cut", onClick = {}, icon = if (withIcons) PhosphorIcons.Regular.Scissors else null)
            ActionBarItem("Copy", onClick = {}, icon = if (withIcons) PhosphorIcons.Regular.Copy else null)
            ActionBarItem("Paste", onClick = {}, icon = if (withIcons) PhosphorIcons.Regular.ClipboardText else null)
            ActionBarSeparator()
            ActionBarItem(
                "Delete",
                onClick = {},
                variant = MenuItemVariant.Destructive,
                icon = if (withIcons) PhosphorIcons.Regular.Trash else null,
            )
        }
    }
}

fun ActionBarScope.actionBarViewMenu() {
    ActionBarMenu {
        ActionBarTrigger("View")
        ActionBarContent {
            ActionBarLabel("Appearance")
            ActionBarItem("Zoom in", onClick = {})
            ActionBarItem("Zoom out", onClick = {})
            ActionBarItem("Actual size", onClick = {})
        }
    }
}

Examples

Default

Web

Web preview

import {
  ActionBar,
  ActionBarContent,
  ActionBarItem,
  ActionBarLabel,
  ActionBarMenu,
  ActionBarSeparator,
  ActionBarTrigger,
} from "@/components/patterns/action-bar"
import { Text } from "@/components/ui/text"

export default function ActionBarDemo() {
  return (
    <ActionBar>
      <ActionBarMenu>
        <ActionBarTrigger>File</ActionBarTrigger>
import PhosphorSwift
import SwiftUI

struct ActionBarExample: View {
  var body: some View {
    ActionBarDemo {
      ActionBarFileMenu()
      ActionBarEditMenu()
      ActionBarViewMenu()
    }
  }
}

struct ActionBarDemo<Content: View>: View {
  var dismissible = true
  var moreLabel: LocalizedStringKey = "More actions"
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import com.adamglin.PhosphorIcons
import com.adamglin.phosphoricons.Regular
import com.adamglin.phosphoricons.regular.ClipboardText
import com.adamglin.phosphoricons.regular.Copy
import com.adamglin.phosphoricons.regular.Scissors
import com.adamglin.phosphoricons.regular.Trash
import com.esuiss.ui.components.MenuItemVariant
import com.esuiss.ui.patterns.ActionBar
import com.esuiss.ui.patterns.ActionBarItem

Overflow

Opens the More actions drawer on first render.

React Native
Action bar overflow in React Native, light modeAction bar overflow in React Native, dark mode
import {
  ActionBar,
  ActionBarContent,
  ActionBarItem,
  ActionBarLabel,
  ActionBarMenu,
  ActionBarSeparator,
  ActionBarTrigger,
} from "@/components/patterns/action-bar"
import { Text } from "@/components/ui/text"

export default function ActionBarOverflow() {
  return (
    <ActionBar defaultOpen>
      <ActionBarMenu>
        <ActionBarTrigger>File</ActionBarTrigger>
import PhosphorSwift
import SwiftUI

struct ActionBarOverflowExample: View {
  var body: some View {
    ActionBarDemo(open: true) {
      ActionBarFileMenu()
      ActionBarEditMenu()
      ActionBarViewMenu()
    }
  }
}

struct ActionBarDemo<Content: View>: View {
  var dismissible = true
  var moreLabel: LocalizedStringKey = "More actions"
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import com.adamglin.PhosphorIcons
import com.adamglin.phosphoricons.Regular
import com.adamglin.phosphoricons.regular.ClipboardText
import com.adamglin.phosphoricons.regular.Copy
import com.adamglin.phosphoricons.regular.Scissors
import com.adamglin.phosphoricons.regular.Trash
import com.esuiss.ui.components.MenuItemVariant
import com.esuiss.ui.patterns.ActionBar
import com.esuiss.ui.patterns.ActionBarItem

With icons

Places an icon before each item in the Edit menu.

Web

Web preview

import {
  ClipboardTextIcon,
  CopyIcon,
  ScissorsIcon,
  TrashIcon,
} from "phosphor-react-native"
import {
  ActionBar,
  ActionBarContent,
  ActionBarItem,
  ActionBarLabel,
  ActionBarMenu,
  ActionBarSeparator,
  ActionBarTrigger,
} from "@/components/patterns/action-bar"
import { Icon } from "@/components/ui/icon"
import PhosphorSwift
import SwiftUI

struct ActionBarWithIconsExample: View {
  var body: some View {
    ActionBarDemo {
      ActionBarFileMenu()
      ActionBarEditMenu(withIcons: true)
      ActionBarViewMenu()
    }
  }
}

struct ActionBarDemo<Content: View>: View {
  var dismissible = true
  var moreLabel: LocalizedStringKey = "More actions"
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import com.adamglin.PhosphorIcons
import com.adamglin.phosphoricons.Regular
import com.adamglin.phosphoricons.regular.ClipboardText
import com.adamglin.phosphoricons.regular.Copy
import com.adamglin.phosphoricons.regular.Scissors
import com.adamglin.phosphoricons.regular.Trash
import com.esuiss.ui.components.MenuItemVariant
import com.esuiss.ui.patterns.ActionBar
import com.esuiss.ui.patterns.ActionBarItem

Not dismissible

Set dismissible to false so sheets ignore outside presses and close only through an action or Cancel.

Web

Web preview

import {
  ActionBar,
  ActionBarContent,
  ActionBarItem,
  ActionBarMenu,
  ActionBarSeparator,
  ActionBarTrigger,
} from "@/components/patterns/action-bar"
import { Text } from "@/components/ui/text"

export default function ActionBarNotDismissible() {
  return (
    <ActionBar dismissible={false}>
      <ActionBarMenu>
        <ActionBarTrigger>File</ActionBarTrigger>
        <ActionBarContent>
import PhosphorSwift
import SwiftUI

struct ActionBarNotDismissibleExample: View {
  var body: some View {
    ActionBarDemo(dismissible: false) {
      ActionBarFileMenu()
      ActionBarEditMenu()
    }
  }
}

struct ActionBarDemo<Content: View>: View {
  var dismissible = true
  var moreLabel: LocalizedStringKey = "More actions"
  var cancelLabel: LocalizedStringKey = "Cancel"
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import com.adamglin.PhosphorIcons
import com.adamglin.phosphoricons.Regular
import com.adamglin.phosphoricons.regular.ClipboardText
import com.adamglin.phosphoricons.regular.Copy
import com.adamglin.phosphoricons.regular.Scissors
import com.adamglin.phosphoricons.regular.Trash
import com.esuiss.ui.components.MenuItemVariant
import com.esuiss.ui.patterns.ActionBar
import com.esuiss.ui.patterns.ActionBarItem

Custom labels

Use moreLabel to rename the More actions button and cancelLabel to rename the Cancel button of each sheet.

Web

Web preview

import {
  ActionBar,
  ActionBarContent,
  ActionBarItem,
  ActionBarMenu,
  ActionBarSeparator,
  ActionBarTrigger,
} from "@/components/patterns/action-bar"
import { Text } from "@/components/ui/text"

export default function ActionBarCustomLabels() {
  return (
    <ActionBar moreLabel="Document actions" cancelLabel="Close">
      <ActionBarMenu>
        <ActionBarTrigger>File</ActionBarTrigger>
        <ActionBarContent>
import PhosphorSwift
import SwiftUI

struct ActionBarCustomLabelsExample: View {
  var body: some View {
    ActionBarDemo(moreLabel: "Document actions", cancelLabel: "Close") {
      ActionBarFileMenu()
      ActionBarEditMenu()
    }
  }
}

struct ActionBarDemo<Content: View>: View {
  var dismissible = true
  var moreLabel: LocalizedStringKey = "More actions"
  var cancelLabel: LocalizedStringKey = "Cancel"
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import com.adamglin.PhosphorIcons
import com.adamglin.phosphoricons.Regular
import com.adamglin.phosphoricons.regular.ClipboardText
import com.adamglin.phosphoricons.regular.Copy
import com.adamglin.phosphoricons.regular.Scissors
import com.adamglin.phosphoricons.regular.Trash
import com.esuiss.ui.components.MenuItemVariant
import com.esuiss.ui.patterns.ActionBar
import com.esuiss.ui.patterns.ActionBarItem

Floating

Set floating to inset the drawer from the screen edges. Without it, the drawer's top corners are square.

Web

Web preview

import {
  ActionBar,
  ActionBarContent,
  ActionBarItem,
  ActionBarLabel,
  ActionBarMenu,
  ActionBarSeparator,
  ActionBarTrigger,
} from "@/components/patterns/action-bar"
import { Text } from "@/components/ui/text"

export default function ActionBarFloating() {
  return (
    <ActionBar floating defaultOpen>
      <ActionBarMenu>
        <ActionBarTrigger>File</ActionBarTrigger>
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import com.adamglin.PhosphorIcons
import com.adamglin.phosphoricons.Regular
import com.adamglin.phosphoricons.regular.ClipboardText
import com.adamglin.phosphoricons.regular.Copy
import com.adamglin.phosphoricons.regular.Scissors
import com.adamglin.phosphoricons.regular.Trash
import com.esuiss.ui.components.MenuItemVariant
import com.esuiss.ui.patterns.ActionBar
import com.esuiss.ui.patterns.ActionBarItem

The React Native tab shows 1 more example.

Accessibility

  • The More actions button and the drawer are labelled by moreLabel.
  • Each drawer row has the button role and exposes its disabled state.
  • The chevron flips in right-to-left layouts.

API Reference

ActionBar

The root that renders the More actions button, its drawer and each menu's sheet.

PropTypeDefault
openboolean-
defaultOpenbooleanfalse
onOpenChange(open: boolean) => void-
dismissiblebooleantrue
floatingboolean-
moreLabelstring"More actions"
cancelLabelstring"Cancel"

Also accepts the props of ViewProps.

Each child should be an ActionBarMenu containing one ActionBarTrigger and one ActionBarContent. The bar renders every child twice, once as a drawer row and once as a sheet, and pairs them by child index. open, defaultOpen and onOpenChange control the drawer.

ActionBarMenu

One menu; a row in the drawer and an AlertSheet for its items.

PropTypeDefault
openboolean-
defaultOpenboolean-
onOpenChange(open: boolean) => void-
childrenReact.ReactNode-

Its own open, defaultOpen and onOpenChange control the menu's sheet.

ActionBarTrigger

The drawer row that opens the menu's sheet, with a trailing chevron.

PropTypeDefault
childrenReact.ReactNode-

Also accepts the props of React.ComponentProps<typeof Pressable>.

A string child is wrapped in Text.

ActionBarContent

The menu's items in an AlertSheetContent, followed by a Cancel button.

Also accepts the props of React.ComponentProps<typeof AlertSheetContent>.

ActionBarLabel

A title shown at the top of the sheet.

Also accepts the props of React.ComponentProps<typeof AlertSheetTitle>.

ActionBarItem

An actionable entry, rendered as an AlertSheetAction.

Also accepts the props of React.ComponentProps<typeof AlertSheetAction>.

ActionBarSeparator

Kept for API parity; renders nothing.

PropTypeDefault
classNamestring-

ActionBar

The root that renders the More actions button, its drawer and each menu's sheet.

ParameterTypeDefault
isPresentedBinding<Bool>?nil
dismissibleBooltrue
moreLabelLocalizedStringKey"More actions"
cancelLabelLocalizedStringKey"Cancel"
content() -> Content-

ActionBarMenu

One menu; a row in the drawer and an AlertSheet for its items.

ParameterTypeDefault
isPresentedBinding<Bool>?nil
content() -> Content-
label() -> Label-
_ย titleLocalizedStringKey-

Overloads: init(isPresented:content:label:), init(_:isPresented:content:).

ActionBarScope.ActionBarMenu

ParameterTypeDefault
openBoolean?null
onOpenChange(Boolean) -> Unit{}
defaultOpenBooleanfalse
contentActionBarMenuScope.() -> Unit-

ActionBarMenuScope.ActionBarTrigger

ParameterTypeDefault
textString-
enabledBooleantrue

ActionBarMenuScope.ActionBarContent

ParameterTypeDefault
modifierModifierModifier
content@Composable () -> Unit-

ActionBar

The root that renders the More actions button, its drawer and each menu's sheet.

ParameterTypeDefault
openBoolean-
onOpenChange(Boolean) -> Unit-
modifierModifierModifier
dismissibleBooleantrue
floatingBooleanfalse
moreLabelString"More actions"
cancelLabelString"Cancel"
contentActionBarScope.() -> Unit-

ActionBarLabel

A title shown at the top of the sheet.

ParameterTypeDefault
textString-
modifierModifierModifier

ActionBarItem

An actionable entry, rendered as an AlertSheetAction.

ParameterTypeDefault
textString-
onClick() -> Unit-
modifierModifierModifier
variantMenuItemVariantMenuItemVariant.Default
enabledBooleantrue
iconImageVector?null

ActionBarSeparator

Kept for API parity; renders nothing.

Takes no parameters.

NextAction MenuPreviousPatterns

On this page

  1. 01Installation
  2. 02Usage
  3. 03Examples
    • With icons
    • By default
    • Not dismissible
    • Custom labels
    • Floating
  4. 04Accessibility
  5. 05API Reference
    • ActionBar
    • ActionBarMenu
    • ActionBarTrigger
    • ActionBarContent
    • ActionBarLabel
    • ActionBarItem
    • ActionBarSeparator
    • ActionBarShortcut
  6. 06Installation
  7. 07Usage
  8. 08Examples
    • Default
    • Overflow
    • With icons
    • Not dismissible
    • Custom labels
    • Floating
  9. 09Accessibility
  10. 10API Reference
    • ActionBar
    • ActionBarMenu
    • ActionBarTrigger
    • ActionBarContent
    • ActionBarLabel
    • ActionBarItem
    • ActionBarSeparator
    • ActionBar
    • ActionBarMenu
    • ActionBarScope.ActionBarMenu
    • ActionBarMenuScope.ActionBarTrigger
    • ActionBarMenuScope.ActionBarContent
    • ActionBar
    • ActionBarLabel
    • ActionBarItem
    • ActionBarSeparator