Skyroc UI
底层原语

Arrow

用于浮层指向触发元素的 SVG 箭头组件

箭头(Arrow)用于在 Tooltip、Popover、HoverCard 等浮层组件中绘制指向触发元素的箭头。它本身是一个 SVG 基础组件,不包含定位逻辑,通常配合浮层内容的定位结果一起使用。

import { Arrow, type ArrowProps } from '@skyroc/web-ui';

架构说明

Arrow 直接从 @radix-ui/react-arrow 导出,项目没有额外封装样式、尺寸或行为。

  • 组件职责:渲染一个可自定义尺寸、填充色和描边色的 SVG 箭头。
  • 样式职责:通过 classNamefillstroke 或 CSS 控制视觉表现。
  • 定位职责:由使用它的浮层组件负责,Arrow 不自行计算方向或位置。

何时使用

  • 浮层需要明确指向触发元素时。
  • 需要复用 Radix Arrow 的 SVG 结构,同时使用项目主题色控制 fill / stroke 时。
  • 自定义 Tooltip、Popover、Dropdown 等浮层内容,并希望箭头和浮层背景保持一致时。

基础用法

通过 widthheight 控制箭头尺寸,通过 className 设置填充色和描边色。

Preview
Code
Loading...

尺寸与颜色

Arrow 不提供项目级 size 属性,尺寸由 SVG 的 widthheight 决定。

属性说明示例
widthSVG 宽度24
heightSVG 高度12
className控制填充色、描边色等样式fill-popover stroke-border
fill直接设置 SVG 填充色"currentColor"
stroke直接设置 SVG 描边色"currentColor"

API

Arrow

通用属性参考:基于 Radix UI Arrow,支持 SVG 元素的所有属性,并额外支持 asChild

属性说明类型默认值
asChild将渲染委托给子元素,合并 props 和行为booleanfalse
children子节点;通常不需要传入ReactNode-
classNameSVG 的 class,用于控制 fill、stroke、尺寸等样式string-
widthSVG 宽度number | string-
heightSVG 高度number | string-
fillSVG 填充色string-
strokeSVG 描边色string-
viewBoxSVG 视口string-
style行内样式CSSProperties-
ref指向底层 SVG 元素的 refRef<SVGSVGElement>-

类型

ArrowProps

Arrow 组件属性,完全来自 Radix Arrow。

字段类型说明
...PrimitiveSvgPropsPrimitiveSvgProps继承 Radix Primitive svg 的全部属性。

PrimitiveSvgProps

Radix Primitive svg 属性。

字段类型说明
...React.ComponentPropsWithoutRef<typeof Primitive.svg>React.ComponentPropsWithoutRef<typeof Primitive.svg>继承 Primitive.svg 的无 ref 属性。

Primitive.svg

Radix Primitive 中的 svg 元素封装。

字段类型说明
propsPrimitivePropsWithRef<"svg">SVG 元素属性,并额外支持 asChild。
refRef<SVGSVGElement>转发到底层 SVG 元素的 ref。

PrimitivePropsWithRef<E>

Radix Primitive 通用属性类型。

字段类型说明
...React.ComponentPropsWithRef<E>React.ComponentPropsWithRef<E>继承指定元素的原生属性和 ref。
asChildboolean将渲染委托给子元素。

React.ComponentPropsWithRef<"svg">

React SVG 元素属性集合。

字段类型说明
childrenReactNodeSVG 子节点。
classNamestringSVG class。
fillstringSVG 填充色。
heightnumber | stringSVG 高度。
onClickMouseEventHandler<SVGSVGElement>点击事件。
refRef<SVGSVGElement>SVG 元素 ref。
strokestringSVG 描边色。
styleCSSProperties行内样式。
viewBoxstringSVG 视口。
widthnumber | stringSVG 宽度。
...SVGAttributes<SVGSVGElement>SVGAttributes<SVGSVGElement>支持其余标准 SVG 属性与事件。

ArrowRef

Arrow 组件 ref 指向的元素

On this page