suiss/ui · Block
Roles Editor
A role editor that lists roles beside grouped permission switches, with save and revert for unsaved changes.
Roles Editor is an open-source block 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.
A role editor with roles and their permission counts on the left and the selected role's permissions on the right as grouped switches. Revert and Save appear only when there are unsaved changes. It combines Sidebar navigation with a SplitView, so on mobile the role list and editor show one at a time. Use it for any role-based access control screen.
Installation
CLI
Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:
Manual
- Install the dependencies:
-
Add the pieces it builds on: Button, Item, Sidebar, Split View, Switch.
-
Copy the source into
components/blocks/roles-editor.tsx:
- Update the import paths to match your project.
Usage
Edit groups for the permissions, roles and members for the role list, and defaults for each role's starting switches. The defaults arrays are positional, mapping to permissions in the order they appear across all groups, so keep them in step with groups or switch to keyed data. Save only updates local state, so call your API there, and give New Role a handler.

A SplitView lists the Editor, Support and Viewer roles with their member counts, and the detail pane shows the selected role's permissions grouped into ItemGroup lists, each with a Switch. Revert and Save buttons appear once a switch changes, and a New Role Button sits under the list. An admin TabBar switches between Users, Roles, Activity and Settings; sections other than Roles show a placeholder. On wide screens the list and detail sit side by side.
Installation
The CLI also adds what it builds on: Button, Icon, Item, Screen, Split View, Switch, Tab Bar, Text. On React Native it also adds the animated view components/ui/animated-view.tsx.
Manual
- Install the dependencies:
-
Add the pieces it builds on: Button, Icon, Item, Screen, Split View, Switch, Tab Bar, Text, and the animated view
components/ui/animated-view.tsxfrom the next step. -
Copy the animated view into
components/ui/animated-view.tsx:
- Copy the source into
components/blocks/roles-editor.tsx:
- Update the import paths to match your project.
- Install the dependencies:
-
Add the pieces it builds on: Button, Icon, Item, Screen, Split View, Switch, Tab Bar, Text, and the animated view
components/ui/animated-view.tsxfrom the next step. -
Copy the animated view into
components/ui/animated-view.tsx:
- Copy the source into
components/blocks/roles-editor.tsx:
- Update the import paths to match your project.
- Install the dependencies:
-
Add the pieces it builds on: Button, Icon, Item, Screen, Split View, Switch, Tab Bar, Text, and the animated view
components/ui/animated-view.tsxfrom the next step. -
Copy the animated view into
components/ui/animated-view.tsx:
- Copy the source into
components/blocks/roles-editor.tsx:
- Update the import paths to match your project.
-
Target iOS 17 or later.
-
Add the Swift package to your app:
- Copy the theme files every view uses:
- Copy the source and every file it uses:
- Add the files to your app target.
- Set
minSdkto 24 or higher and add the dependencies:
- Copy the theme files every view uses:
- Copy the source and every file it uses:
- Update the
com.esuiss.uipackage names to match your project.
Usage
Replace GROUPS, ROLES, MEMBERS and DEFAULTS with your permissions and grants. Use onTogglePermission, onSave, onRevert, onNewRole and onNavigate to persist changes and route between sections.
