Member List
A server member sidebar: role sections, presence, coloured names and APP tags.
A server member sidebar: role sections, presence, coloured names and APP tags. Compose it from the exported registry parts so local content and behaviour stay in the application while the visual contract stays token-driven.
newt-memberimport { Avatar } from "@/registry/bases/newt/ui/avatar"
import {
MemberList,
MemberListAppTag,
MemberListHeading,
MemberListInfo,
MemberListItem,
MemberListName,
MemberListNameRow,
MemberListRole,
MemberListSection,
} from "@/registry/bases/newt/ui/member-list"
import { RoleTag } from "@/registry/bases/newt/ui/role-tag"
import {
StatusDot,
StatusIndicator,
} from "@/registry/bases/newt/ui/status-indicator"
/*
* Each section holds a heading and its own list. The section links the two,
* so a screen reader names each list by its heading.
*/
export default function MemberListDemo() {
return (
<div className="w-60">
<MemberListSection>
<MemberListHeading>Moderators — 1</MemberListHeading>
<MemberList>
<MemberListItem>
<StatusIndicator>
<Avatar size="md">A</Avatar>
<StatusDot status="online" label="Online" />
</StatusIndicator>
<MemberListInfo>
<MemberListNameRow>
<MemberListName color="var(--newt-idle)">
username
</MemberListName>
<MemberListAppTag verified />
</MemberListNameRow>
<MemberListRole>Role</MemberListRole>
</MemberListInfo>
<RoleTag className="ms-auto">TAG</RoleTag>
</MemberListItem>
</MemberList>
</MemberListSection>
<MemberListSection offline>
<MemberListHeading>Offline — 1</MemberListHeading>
<MemberList>
<MemberListItem>
<StatusIndicator>
<Avatar size="md">B</Avatar>
<StatusDot status="offline" label="Offline" />
</StatusIndicator>
<MemberListInfo>
<MemberListNameRow>
<MemberListName>someone</MemberListName>
</MemberListNameRow>
</MemberListInfo>
</MemberListItem>
</MemberList>
</MemberListSection>
</div>
)
}<script setup lang="ts">
import { Avatar } from "~~/registry/bases/newt/ui/avatar"
import {
MemberList,
MemberListAppTag,
MemberListHeading,
MemberListInfo,
MemberListItem,
MemberListName,
MemberListNameRow,
MemberListRole,
MemberListSection,
} from "~~/registry/bases/newt/ui/member-list"
import { RoleTag } from "~~/registry/bases/newt/ui/role-tag"
import {
StatusDot,
StatusIndicator,
} from "~~/registry/bases/newt/ui/status-indicator"
/*
* Each section holds a heading and its own list. The section links the two,
* so a screen reader names each list by its heading.
*/
</script>
<template>
<div class="w-60">
<MemberListSection>
<MemberListHeading>Moderators — 1</MemberListHeading>
<MemberList>
<MemberListItem>
<StatusIndicator>
<Avatar size="md">A</Avatar>
<StatusDot status="online" label="Online" />
</StatusIndicator>
<MemberListInfo>
<MemberListNameRow>
<MemberListName color="var(--newt-idle)">username</MemberListName>
<MemberListAppTag verified />
</MemberListNameRow>
<MemberListRole>Role</MemberListRole>
</MemberListInfo>
<RoleTag class="ms-auto">TAG</RoleTag>
</MemberListItem>
</MemberList>
</MemberListSection>
<MemberListSection offline>
<MemberListHeading>Offline — 1</MemberListHeading>
<MemberList>
<MemberListItem>
<StatusIndicator>
<Avatar size="md">B</Avatar>
<StatusDot status="offline" label="Offline" />
</StatusIndicator>
<MemberListInfo>
<MemberListNameRow>
<MemberListName>someone</MemberListName>
</MemberListNameRow>
</MemberListInfo>
</MemberListItem>
</MemberList>
</MemberListSection>
</div>
</template>Installation
npx newtui@latest add member-listnpx shadcn@latest add @newtui/member-listnpx shadcn-vue@latest add @newtui/member-listpnpm dlx newtui@latest add member-listpnpm dlx shadcn@latest add @newtui/member-listpnpm dlx shadcn-vue@latest add @newtui/member-listyarn dlx newtui@latest add member-listyarn dlx shadcn@latest add @newtui/member-listyarn dlx shadcn-vue@latest add @newtui/member-listbunx newtui@latest add member-listbunx shadcn@latest add @newtui/member-listbunx shadcn-vue@latest add @newtui/member-listdeno run -A npm:newtui@latest add member-listdeno run -A npm:shadcn@latest add @newtui/member-listdeno run -A npm:shadcn-vue@latest add @newtui/member-listvlx newtui@latest add member-listvlx shadcn@latest add @newtui/member-listvlx shadcn-vue@latest add @newtui/member-listvp dlx newtui@latest add member-listvp dlx shadcn@latest add @newtui/member-listvp dlx shadcn-vue@latest add @newtui/member-listnubx newtui@latest add member-listnubx shadcn@latest add @newtui/member-listnubx shadcn-vue@latest add @newtui/member-listnlx newtui@latest add member-listnlx shadcn@latest add @newtui/member-listnlx shadcn-vue@latest add @newtui/member-listupx newtui@latest add member-listupx shadcn@latest add @newtui/member-listupx shadcn-vue@latest add @newtui/member-list- newtui
- shadcn
- npm
- pnpm
- yarn
- bun
- deno
- vlt
- vp
- nub
- ni
- upm
The shadcn CLI needs the @newtui registry in your components.json. Set it up.
Add the components it builds on
Copy the source into your project
"use client"
import * as React from "react"
import { cn } from "@/lib/utils"
/*
* The composition:
*
* MemberListSection <section>
* MemberListHeading <h3 id>
* MemberList role="list", aria-labelledby the heading
* MemberListItem role="listitem"
*
* A heading is never a child of the list, which may own only list items.
* The section generates one id, the heading takes it and the list points at
* it, so each list is named by its heading. A list outside a section takes
* an `aria-label` instead.
*/
const MemberListSectionContext = React.createContext<string | undefined>(
undefined
)
const MemberList = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(
(
{
className,
"aria-label": ariaLabel,
"aria-labelledby": ariaLabelledby,
...props
},
ref
) => {
const headingId = React.useContext(MemberListSectionContext)
return (
<div
ref={ref}
role="list"
aria-label={ariaLabel}
aria-labelledby={
ariaLabelledby ?? (ariaLabel === undefined ? headingId : undefined)
}
className={cn("flex flex-col", className)}
{...props}
/>
)
}
)
MemberList.displayName = "MemberList"
/*
* Discord groups members under each hoisted role, then Online, then Offline.
* `offline` dims the whole group rather than every row on its own.
*/
export interface MemberListSectionProps extends React.HTMLAttributes<HTMLElement> {
offline?: boolean
}
const MemberListSection = React.forwardRef<HTMLElement, MemberListSectionProps>(
({ className, offline = false, ...props }, ref) => {
const headingId = React.useId()
return (
<MemberListSectionContext.Provider value={headingId}>
<section
ref={ref}
data-offline={offline || undefined}
className={cn(
"[&:not(:first-child)]:mt-3",
offline &&
"[&_[role=listitem]]:opacity-45 [&_[data-slot=member-name]]:text-newt-text-muted",
className
)}
{...props}
/>
</MemberListSectionContext.Provider>
)
}
)
MemberListSection.displayName = "MemberListSection"
export interface MemberListHeadingProps extends React.HTMLAttributes<HTMLHeadingElement> {
/** The heading level. Pick the one that fits the outline of the page. */
as?: "h2" | "h3" | "h4" | "h5" | "h6"
}
/*
* Inside a section the heading takes the id the section generated, so the
* list beside it is named by it. If you pass an `id` of your own, pass the
* same id as `aria-labelledby` on the `MemberList`.
*/
const MemberListHeading = React.forwardRef<
HTMLHeadingElement,
MemberListHeadingProps
>(({ className, as: Heading = "h3", id, ...props }, ref) => {
const headingId = React.useContext(MemberListSectionContext)
return (
<Heading
ref={ref}
id={id ?? headingId}
className={cn(
"m-0 px-2 pb-0.5 text-[12px] font-semibold uppercase leading-4 tracking-[0.02em] text-newt-text-muted",
className
)}
{...props}
/>
)
})
MemberListHeading.displayName = "MemberListHeading"
interface MemberListItemOwnProps {
/**
* An underlay drawn behind the row, such as a profile decoration. The hover
* is drawn over it, so it stays visible. An `img` fills the row.
*/
decoration?: React.ReactNode
}
/*
* `interactive` picks the element, so it also picks the attributes: a plain
* row takes the attributes of a `div`, an interactive row those of a
* `button`, such as `disabled`, `name` and `value`.
*/
export type MemberListItemProps =
| (MemberListItemOwnProps &
React.HTMLAttributes<HTMLDivElement> & {
interactive?: false
})
| (MemberListItemOwnProps &
React.ButtonHTMLAttributes<HTMLButtonElement> & {
/**
* Make the row a button, for a row that opens a profile. It takes
* focus, answers Enter and Space, and shows a hover and a focus
* ring. Every attribute and listener, and the ref, land on the
* button.
*/
interactive: true
})
const MEMBER_ROW =
"relative isolate flex min-w-0 items-center gap-2.5 rounded-[var(--newt-radius-sm)] px-2 py-1.5"
const MEMBER_ROW_INTERACTIVE =
"w-full cursor-pointer border-0 bg-transparent text-start after:pointer-events-none after:absolute after:inset-0 after:-z-10 after:rounded-[inherit] after:transition-colors after:duration-fast after:ease-newt after:content-[''] hover:after:bg-newt-bg-hover focus-visible:outline focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-newt-text-link"
/*
* One member. A plain row has no pointer and no hover, because it does
* nothing. With `interactive` the row is a button inside the list item.
*/
const MemberListItem = React.forwardRef<HTMLElement, MemberListItemProps>(
({ className, interactive = false, decoration, children, ...props }, ref) => {
/*
* `createElement` types the ref by the element it is given, so one
* `HTMLElement` ref serves the `div` and the `button` without an
* assertion.
*/
const row = React.createElement(
interactive ? "button" : "div",
{
ref,
type: interactive ? "button" : undefined,
role: interactive ? undefined : "listitem",
className: cn(
MEMBER_ROW,
interactive && MEMBER_ROW_INTERACTIVE,
className
),
...props,
},
decoration === undefined ? null : (
<span
aria-hidden="true"
className="pointer-events-none absolute inset-0 -z-10 overflow-hidden rounded-[inherit] [&>img]:h-full [&>img]:w-full [&>img]:object-cover"
>
{decoration}
</span>
),
children
)
return interactive ? <div role="listitem">{row}</div> : row
}
)
MemberListItem.displayName = "MemberListItem"
const MemberListNameRow = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
<div
ref={ref}
className={cn("flex min-w-0 items-center gap-1", className)}
{...props}
/>
))
MemberListNameRow.displayName = "MemberListNameRow"
const MemberListInfo = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
<div
ref={ref}
className={cn("flex min-w-0 flex-col leading-[1.2]", className)}
{...props}
/>
))
MemberListInfo.displayName = "MemberListInfo"
export interface MemberListNameProps extends Omit<
React.HTMLAttributes<HTMLSpanElement>,
"color"
> {
/** Render the name in the brand colour (e.g. highlighted role). */
colored?: boolean
/** Role colour. Any CSS colour; wins over `colored`. */
color?: string
}
const MemberListName = React.forwardRef<HTMLSpanElement, MemberListNameProps>(
({ className, colored = false, color, style, ...props }, ref) => (
<span
ref={ref}
data-slot="member-name"
/*
* SAFETY: `CSSProperties` has no index signature for custom properties,
* but React forwards unknown `--*` keys to the style attribute verbatim,
* so the extra key is written out exactly as spelled here.
*/
style={
color
? ({
...style,
"--newt-member-name-color": color,
} as React.CSSProperties)
: style
}
className={cn(
"truncate text-sm font-medium",
color
? "text-[var(--newt-member-name-color)]"
: colored
? "text-newt-brand"
: "text-newt-text-primary",
className
)}
{...props}
/>
)
)
MemberListName.displayName = "MemberListName"
/* The APP tag bots carry next to their name; `verified` adds Discord's check. */
export interface MemberListAppTagProps extends React.HTMLAttributes<HTMLSpanElement> {
verified?: boolean
/** Accessible name of the tag. `aria-label` still wins. */
label?: string
/** Accessible name with `verified`. `aria-label` still wins. */
verifiedLabel?: string
}
const MemberListAppTag = React.forwardRef<
HTMLSpanElement,
MemberListAppTagProps
>(
(
{
className,
verified = false,
label = "Application",
verifiedLabel = "Verified application",
children = "APP",
...props
},
ref
) => (
<span
ref={ref}
role="img"
aria-label={verified ? verifiedLabel : label}
className={cn(
"inline-flex shrink-0 items-center gap-0.5 rounded-[var(--newt-radius-sm)] bg-newt-brand px-1 py-px text-[9px] font-bold leading-none text-newt-on-accent",
className
)}
{...props}
>
{verified ? (
<svg
viewBox="0 0 24 24"
aria-hidden="true"
focusable="false"
className="h-2.5 w-2.5"
>
<path
fill="currentColor"
d="M9.55 17.6 4.4 12.45l1.4-1.4 3.75 3.75 8.65-8.65 1.4 1.4z"
/>
</svg>
) : null}
{children}
</span>
)
)
MemberListAppTag.displayName = "MemberListAppTag"
const MemberListRole = React.forwardRef<
HTMLSpanElement,
React.HTMLAttributes<HTMLSpanElement>
>(({ className, ...props }, ref) => (
<span
ref={ref}
className={cn("truncate text-xs text-newt-text-muted", className)}
{...props}
/>
))
MemberListRole.displayName = "MemberListRole"
export {
MemberList,
MemberListSection,
MemberListHeading,
MemberListItem,
MemberListInfo,
MemberListNameRow,
MemberListName,
MemberListAppTag,
MemberListRole,
}<script setup lang="ts">
import { computed, inject, type HTMLAttributes } from "vue"
import { cn } from "@/lib/utils"
import { memberListSectionKey } from "."
const props = defineProps<{
class?: HTMLAttributes["class"]
ariaLabel?: string
ariaLabelledby?: string
}>()
/* Inside a section, the list is named by the heading of that section. */
const headingId = inject(memberListSectionKey, undefined)
const labelledby = computed(
() =>
props.ariaLabelledby ??
(props.ariaLabel === undefined ? headingId : undefined)
)
</script>
<template>
<div
role="list"
:aria-label="props.ariaLabel"
:aria-labelledby="labelledby"
:class="cn('flex flex-col', props.class)"
>
<slot />
</div>
</template><script setup lang="ts">
import { provide, useId, type HTMLAttributes } from "vue"
import { cn } from "@/lib/utils"
import { memberListSectionKey } from "."
/*
* Discord groups members under each hoisted role, then Online, then Offline.
* `offline` dims the whole group rather than every row on its own.
*/
const props = defineProps<{
class?: HTMLAttributes["class"]
offline?: boolean
}>()
provide(memberListSectionKey, useId())
</script>
<template>
<section
:data-offline="props.offline || undefined"
:class="
cn(
'[&:not(:first-child)]:mt-3',
props.offline &&
'[&_[role=listitem]]:opacity-45 [&_[data-slot=member-name]]:text-newt-text-muted',
props.class
)
"
>
<slot />
</section>
</template><script setup lang="ts">
import { inject, type HTMLAttributes } from "vue"
import { cn } from "@/lib/utils"
import { memberListSectionKey } from "."
/*
* Inside a section the heading takes the id the section generated, so the
* list beside it is named by it. If you pass an `id` of your own, pass the
* same id as `aria-labelledby` on the `MemberList`.
*/
const props = withDefaults(
defineProps<{
class?: HTMLAttributes["class"]
/** The heading level. Pick the one that fits the outline of the page. */
as?: "h2" | "h3" | "h4" | "h5" | "h6"
id?: string
}>(),
{ as: "h3" }
)
const headingId = inject(memberListSectionKey, undefined)
</script>
<template>
<component
:is="props.as"
:id="props.id ?? headingId"
:class="
cn(
'm-0 px-2 pb-0.5 text-[12px] font-semibold uppercase leading-4 tracking-[0.02em] text-newt-text-muted',
props.class
)
"
>
<slot />
</component>
</template><script setup lang="ts">
import { computed, type HTMLAttributes, type VNode } from "vue"
import { cn } from "@/lib/utils"
/*
* One member. A plain row has no pointer and no hover, because it does
* nothing. With `interactive` the row is a button inside the list item, for
* a row that opens a profile: it takes focus, answers Enter and Space, and
* shows a hover and a focus ring. Attributes and listeners land on the row.
*
* The `decoration` slot is an underlay drawn behind the row, such as a
* profile decoration. The hover is drawn over it, so it stays visible. An
* `img` fills the row.
*/
defineOptions({ inheritAttrs: false })
const props = defineProps<{
class?: HTMLAttributes["class"]
interactive?: boolean
}>()
defineSlots<{
default?: () => VNode[]
decoration?: () => VNode[]
}>()
const rowClass = computed(() =>
cn(
"relative isolate flex min-w-0 items-center gap-2.5 rounded-[var(--newt-radius-sm)] px-2 py-1.5",
props.interactive &&
"w-full cursor-pointer border-0 bg-transparent text-start after:pointer-events-none after:absolute after:inset-0 after:-z-10 after:rounded-[inherit] after:transition-colors after:duration-fast after:ease-newt after:content-[''] hover:after:bg-newt-bg-hover focus-visible:outline focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-newt-text-link",
props.class
)
)
</script>
<template>
<div v-if="props.interactive" role="listitem">
<button type="button" v-bind="$attrs" :class="rowClass">
<span
v-if="$slots.decoration"
aria-hidden="true"
class="pointer-events-none absolute inset-0 -z-10 overflow-hidden rounded-[inherit] [&>img]:h-full [&>img]:w-full [&>img]:object-cover"
>
<slot name="decoration" />
</span>
<slot />
</button>
</div>
<div v-else role="listitem" v-bind="$attrs" :class="rowClass">
<span
v-if="$slots.decoration"
aria-hidden="true"
class="pointer-events-none absolute inset-0 -z-10 overflow-hidden rounded-[inherit] [&>img]:h-full [&>img]:w-full [&>img]:object-cover"
>
<slot name="decoration" />
</span>
<slot />
</div>
</template><script setup lang="ts">
import type { HTMLAttributes } from "vue"
import { cn } from "@/lib/utils"
const props = defineProps<{ class?: HTMLAttributes["class"] }>()
</script>
<template>
<div :class="cn('flex min-w-0 flex-col leading-[1.2]', props.class)">
<slot />
</div>
</template><script setup lang="ts">
import type { HTMLAttributes } from "vue"
import { cn } from "@/lib/utils"
const props = defineProps<{ class?: HTMLAttributes["class"] }>()
</script>
<template>
<div :class="cn('flex min-w-0 items-center gap-1', props.class)">
<slot />
</div>
</template><script setup lang="ts">
import type { CSSProperties, HTMLAttributes } from "vue"
import { computed } from "vue"
import { cn } from "@/lib/utils"
const props = defineProps<{
class?: HTMLAttributes["class"]
/** Render the name in the brand colour. */
colored?: boolean
/** Role colour. Any CSS colour; wins over `colored`. */
color?: string
}>()
/*
* SAFETY: `CSSProperties` has no index signature for custom properties, but
* Vue writes unknown `--*` keys to the style attribute verbatim, so the extra
* key lands exactly as spelled here.
*/
const style = computed<CSSProperties | undefined>(() =>
props.color
? ({ "--newt-member-name-color": props.color } as CSSProperties)
: undefined
)
const colorClass = computed(() => {
if (props.color) return "text-[var(--newt-member-name-color)]"
return props.colored ? "text-newt-brand" : "text-newt-text-primary"
})
</script>
<template>
<span
data-slot="member-name"
:style="style"
:class="cn('truncate text-sm font-medium', colorClass, props.class)"
>
<slot />
</span>
</template><script setup lang="ts">
import type { HTMLAttributes } from "vue"
import { cn } from "@/lib/utils"
/* The APP tag bots carry next to their name; `verified` adds Discord's check. */
const props = withDefaults(
defineProps<{
class?: HTMLAttributes["class"]
verified?: boolean
/** Accessible name of the tag. `aria-label` still wins. */
label?: string
/** Accessible name with `verified`. `aria-label` still wins. */
verifiedLabel?: string
}>(),
{ label: "Application", verifiedLabel: "Verified application" }
)
</script>
<template>
<span
role="img"
:aria-label="props.verified ? props.verifiedLabel : props.label"
:class="
cn(
'inline-flex shrink-0 items-center gap-0.5 rounded-[var(--newt-radius-sm)] bg-newt-brand px-1 py-px text-[9px] font-bold leading-none text-newt-on-accent',
props.class
)
"
>
<svg
v-if="props.verified"
viewBox="0 0 24 24"
aria-hidden="true"
focusable="false"
class="h-2.5 w-2.5"
>
<path
fill="currentColor"
d="M9.55 17.6 4.4 12.45l1.4-1.4 3.75 3.75 8.65-8.65 1.4 1.4z"
/>
</svg>
<slot>APP</slot>
</span>
</template><script setup lang="ts">
import type { HTMLAttributes } from "vue"
import { cn } from "@/lib/utils"
const props = defineProps<{ class?: HTMLAttributes["class"] }>()
</script>
<template>
<span :class="cn('truncate text-xs text-newt-text-muted', props.class)">
<slot />
</span>
</template>import type { InjectionKey } from "vue"
export { default as MemberList } from "./MemberList.vue"
export { default as MemberListSection } from "./MemberListSection.vue"
export { default as MemberListHeading } from "./MemberListHeading.vue"
export { default as MemberListItem } from "./MemberListItem.vue"
export { default as MemberListInfo } from "./MemberListInfo.vue"
export { default as MemberListNameRow } from "./MemberListNameRow.vue"
export { default as MemberListName } from "./MemberListName.vue"
export { default as MemberListAppTag } from "./MemberListAppTag.vue"
export { default as MemberListRole } from "./MemberListRole.vue"
/*
* The composition:
*
* MemberListSection <section>
* MemberListHeading <h3 id>
* MemberList role="list", aria-labelledby the heading
* MemberListItem role="listitem"
*
* A heading is never a child of the list, which may own only list items.
* The section generates one id, the heading takes it and the list points at
* it, so each list is named by its heading. A list outside a section takes
* an `aria-label` instead.
*/
export const memberListSectionKey: InjectionKey<string> = Symbol(
"newt-member-list-section"
)Update the import paths
The files import @/lib/utils and sibling components through the aliases in your components.json. Point them at wherever those live in your project.
No CLI, no components.json: paste this into Claude, Cursor, Copilot or any coding assistant and it adds Member List to your React project by hand. The prompt carries the source of every file the CLI would write — this component's and those of the components it builds on — with the imports already pointed at the default aliases.
No CLI, no components.json: paste this into Claude, Cursor, Copilot or any coding assistant and it adds Member List to your Vue project by hand. The prompt carries the source of every file the CLI would write — this component's and those of the components it builds on — with the imports already pointed at the default aliases.
Usage
import { MemberList } from "@/components/ui/member-list"
export function Example() {
return <MemberList />
}<script setup lang="ts">
import { MemberList, MemberListSection, MemberListHeading, MemberListItem, MemberListInfo, MemberListNameRow, MemberListName, MemberListAppTag, MemberListRole } from "@/components/ui/member-list"
</script>
<template>
<MemberList />
</template>Composition
Each group of members is one MemberListSection. The section holds a MemberListHeading and then one MemberList, which holds the MemberListItem rows.
MemberListSection <section>
MemberListHeading <h3>, the name of the list
MemberList role="list"
MemberListItem role="listitem"
The heading is never inside the list, because a list may own only list items. The section generates an id. The heading takes that id, and the list points at it with aria-labelledby, so each list is named by its heading. The id comes from useId in both frameworks, so the server render and the client agree.
A list with no section has no heading to point at. Give it an aria-label. If you give a heading an id of your own, pass the same id as aria-labelledby on its MemberList.
Examples
Rows that open a profile
A plain row does nothing, so it has no pointer and no hover. Add interactive to a row that opens a profile. The row then renders a <button> inside the list item: it takes focus, answers Enter and Space, and shows a hover and a focus ring. Listeners, attributes and the ref land on the button, so the row works as the trigger of a popover. In React, an interactive row also takes the attributes of a button, such as disabled, name and value.
The first row below has a decoration. The hover is drawn over the decoration, so the hover stays visible on an image.
newt-member"use client"
import * as React from "react"
import { Avatar } from "@/registry/bases/newt/ui/avatar"
import {
MemberList,
MemberListHeading,
MemberListInfo,
MemberListItem,
MemberListName,
MemberListNameRow,
MemberListRole,
MemberListSection,
} from "@/registry/bases/newt/ui/member-list"
import {
StatusDot,
StatusIndicator,
} from "@/registry/bases/newt/ui/status-indicator"
const MEMBERS = [
{ name: "juniper", status: "online", label: "Online", role: "Gardener" },
{ name: "sorrel", status: "idle", label: "Idle", role: "Archivist" },
{ name: "thistle", status: "dnd", label: "Do not disturb", role: "Builder" },
] as const
/*
* Rows that open a profile are buttons: Tab reaches each one, and Enter or
* Space opens it. The first row carries a decoration under its hover.
*/
export default function MemberListInteractiveDemo() {
const [opened, setOpened] = React.useState<string>()
return (
<div className="flex w-60 flex-col gap-2">
<MemberListSection>
<MemberListHeading as="h4">Online — 3</MemberListHeading>
<MemberList>
{MEMBERS.map((member, index) => (
<MemberListItem
key={member.name}
interactive
value={member.name}
onClick={(event) => setOpened(event.currentTarget.value)}
decoration={
index === 0 ? (
<span className="block h-full w-full bg-[linear-gradient(90deg,color-mix(in_srgb,var(--newt-brand)_45%,transparent),transparent)]" />
) : undefined
}
>
<StatusIndicator>
<Avatar size="md">{member.name.charAt(0).toUpperCase()}</Avatar>
<StatusDot status={member.status} label={member.label} />
</StatusIndicator>
<MemberListInfo>
<MemberListNameRow>
<MemberListName>{member.name}</MemberListName>
</MemberListNameRow>
<MemberListRole>{member.role}</MemberListRole>
</MemberListInfo>
</MemberListItem>
))}
</MemberList>
</MemberListSection>
<p className="m-0 px-2 text-xs text-newt-text-muted" aria-live="polite">
{opened === undefined ? "No profile open" : `Profile: ${opened}`}
</p>
</div>
)
}<script setup lang="ts">
import { ref } from "vue"
import { Avatar } from "~~/registry/bases/newt/ui/avatar"
import {
MemberList,
MemberListHeading,
MemberListInfo,
MemberListItem,
MemberListName,
MemberListNameRow,
MemberListRole,
MemberListSection,
} from "~~/registry/bases/newt/ui/member-list"
import {
StatusDot,
StatusIndicator,
} from "~~/registry/bases/newt/ui/status-indicator"
/*
* Rows that open a profile are buttons: Tab reaches each one, and Enter or
* Space opens it. The first row carries a decoration under its hover.
*/
const members = [
{ name: "juniper", status: "online", label: "Online", role: "Gardener" },
{ name: "sorrel", status: "idle", label: "Idle", role: "Archivist" },
{ name: "thistle", status: "dnd", label: "Do not disturb", role: "Builder" },
] as const
const opened = ref<string>()
</script>
<template>
<div class="flex w-60 flex-col gap-2">
<MemberListSection>
<MemberListHeading as="h4">Online — 3</MemberListHeading>
<MemberList>
<MemberListItem
v-for="(member, index) in members"
:key="member.name"
interactive
@click="opened = member.name"
>
<template v-if="index === 0" #decoration>
<span
class="block h-full w-full bg-[linear-gradient(90deg,color-mix(in_srgb,var(--newt-brand)_45%,transparent),transparent)]"
/>
</template>
<StatusIndicator>
<Avatar size="md">{{ member.name.charAt(0).toUpperCase() }}</Avatar>
<StatusDot :status="member.status" :label="member.label" />
</StatusIndicator>
<MemberListInfo>
<MemberListNameRow>
<MemberListName>{{ member.name }}</MemberListName>
</MemberListNameRow>
<MemberListRole>{{ member.role }}</MemberListRole>
</MemberListInfo>
</MemberListItem>
</MemberList>
</MemberListSection>
<p class="m-0 px-2 text-xs text-newt-text-muted" aria-live="polite">
{{ opened === undefined ? "No profile open" : `Profile: ${opened}` }}
</p>
</div>
</template>API reference
MemberListSection
offline?boolean
Dims the rows and the names of the group, for members who are offline.
booleanfalseMemberListHeading
as?"h2" | "h3" | "h4" | "h5" | "h6"
The heading level. Pick the one that fits the outline of the page.
"h2" | "h3" | "h4" | "h5" | "h6""h3"MemberList
aria-label?string
The name of a list with no section. Inside a section, the heading names the list.
stringaria-labelledby?string
Overrides the link to the heading of the section. Use it when the heading has an id of your own.
stringMemberListItem
interactive?boolean
Renders the row as a button inside the list item, with a pointer, a hover and a focus ring.
booleanfalsedecoration (React) / #decoration slot (Vue)?React.ReactNode / Vue slot
An underlay drawn behind the row, such as a profile decoration. The hover is drawn over it. An `img` fills the row.
React.ReactNode / Vue slotMemberListName
colored?boolean | undefined
Render the name in the brand colour (e.g. highlighted role).
boolean | undefinedcolor?string | undefined
Role colour. Any CSS colour; wins over `colored`.
string | undefinedMemberListAppTag
verified?boolean | undefined
Adds a check mark for a verified application.
boolean | undefinedlabel?string
Accessible name of the tag. `aria-label` still wins.
string"Application"verifiedLabel?string
Accessible name with `verified`. `aria-label` still wins.
string"Verified application"The registry exports MemberList, MemberListSection, MemberListHeading, MemberListItem, MemberListInfo, MemberListNameRow, MemberListName, MemberListAppTag, MemberListRole. Parts without a table accept the native attributes for the element they render; React uses className, while Vue uses class and fallthrough attributes.
In the plain HTML and CSS distribution, write the ids yourself: give the heading an id and the .newt-member-list the same value in aria-labelledby. An interactive row is a <button class="newt-member newt-member--interactive"> inside a role="listitem" element. A decoration is a .newt-member__decoration span, the first child of the row.
Accessibility
Each list is named by its heading, so a screen reader announces “Moderators, list, 1 item” when it enters a group. Do not put a heading inside a MemberList.
The app tag’s name comes from label and verifiedLabel. Its visible APP is the children or the default slot. Translating labels lists every English default.
A row that does nothing is not focusable and shows no pointer. A row that opens a profile must be interactive, so a keyboard reaches it and Enter opens it. Give the presence dot a label, or write the status in the row, so the state does not depend on colour alone.
Tokens
Member List reads its colours, radii and motion from the --newt-* tokens installed with the library. Override a token and every component that reads it follows, including this one — see the token layer. In the plain HTML and CSS distribution the same component is newt-member.
--newt-text-muted--newt-radius-sm--newt-duration-fast--newt-ease--newt-bg-hover--newt-text-link--newt-text-primary--newt-brand--newt-on-accent