Skip to content
Nacre
Color palette
中文

InlineAction

experimentalInlineAction · InlineLinkOpen in playground
InlineAction
Runs the real component in your browser.

Use InlineAction for commands and InlineLink for destinations in prose.

Status: experimental · Components: InlineAction, InlineLink

import { InlineAction, InlineLink } from 'nacre'

Wrap inline content while preserving caller typography.

import { Text, View, signal } from 'nsh'
import { InlineAction, Icon, TEXT_SIZE } from 'nacre'
export function InlineActionUsage() {
const count = signal(0)
const label = () => 'Open ticket'
return <View class="gap-3 items-start">
<InlineAction testID="inline-action" label={label()} tooltip={label()} onPress={() => count.update((n) => n + 1)}>
<Text class={`${TEXT_SIZE.small} text-muted-foreground`}>Created ticket <Text class="font-medium">C20261125</Text></Text>
</InlineAction>
<InlineAction label="Call back" padded={false} class="flex-row items-center gap-1" onPress={() => count.update((n) => n + 1)}>
<Text class={`${TEXT_SIZE.title} text-foreground`}>138 0000 0000</Text><Icon name="phone" size={12} />
</InlineAction>
<InlineAction testID="inline-disabled" disabled label={label()} onPress={() => count.update((n) => n + 1)}><Text class={`${TEXT_SIZE.small}`}>Unavailable</Text></InlineAction>
<Text testID="inline-count" class={`${TEXT_SIZE.caption} tabular-nums text-muted-foreground`}>{`count=${count()}`}</Text>
</View>
}

Like Radix Themes Link (https://www.radix-ui.com/themes/docs/components/link), the label wraps inline and is underlined. The label may be shorter than the destination. An NSH text span calls onOpen and is not a separate Tab stop inside a paragraph.

import { Text, View, signal } from 'nsh'
import { InlineLink, TEXT_SIZE } from 'nacre'
export function InlineLinkUsage() {
const target = signal('')
const href = 'https://example.com/help'
return (
<View class="gap-2">
<Text testID="demo-link-paragraph" class={`${TEXT_SIZE.body} text-foreground`}>
See:
<InlineLink testID="demo-inline-link" label="example.com/help" href={href} onOpen={(url) => target.set(url)} />
</Text>
<Text class={`${TEXT_SIZE.small} text-muted-foreground`}>{target()}</Text>
</View>
)
}
Key Action
Tab Focus the entry
Space / Return Activate
  • InlineAction uses label as its button name. InlineLink has a link role: a standalone link is named by its full href, a macOS link inside a paragraph by its visible text.

Do

  • Keep the accessible name
  • Change color on press without scaling

Don’t

  • Nest interactive controls

Property descriptions follow the Chinese source comments.

Prop Type Default Description
label * string — 读屏名;内容可以有分段字重与外部字阶
tooltip string —
padded boolean — 默认水平内缩 6pt;贴齐外部文字时关闭
disabled boolean —
onPress () => void —
class string —
testID string —
viewRef (node: ViewRef) => void —
children JSX.Element —

* required

Prop Type Default Description
label * string — 显示的文字;可短于完整地址
href * string — 完整目的地,由调用方打开;独立链接以此命名,macOS 段内链接读可见文字
onOpen * (href: string) => void —
tone 'brand' | 'neutral' | 'inverse' — 默认品牌链接色;次要资料用正文色,品牌实底用反色,始终保留下划线
class string —
testID string —

* required