Component

Banner

安装 Installation

npx timkit add banner --yes --framework react

用法 Usage

import { Banner } from "@/components/ui/banner"

className 与 variant、size 可以一起用。字段以 timkit agent inspect banner --json 的 props 为准。

示例

Examples

一次看一个示例。左侧按名称筛选,预览里可切换源码和框架。

12 / 12

Banner · Outlined Style

Loading preview...

结构化 API

Structured API

与 UCS schema 对齐的 props、逻辑机与多框架运行时。

Component

banner

Logic

none

Runtime Frameworks

ReactVueWeappHTML

Supported Platforms

WebWeChat Mini Program

Configuration

PropTypeDefaultDescription
logic.provider*
enum (zag | native | none)
noneState and interaction provider used by this component.
logic.machine
string
-Underlying state machine identifier when provider is zag.
platforms*
array
Web, WeChat Mini ProgramPlatforms officially supported by this schema.
frameworks*
array
React, Vue, Weapp, HTMLFramework demos/code currently available in registry files.
dependencies
array
@timui/coreRuntime package dependencies required by this registry item.
optionalPeerDependencies
array
-Optional peer dependencies used by this registry item.
registryDependencies
array
-Dependent Timkit registry components/hook entries.

Props

PropTypeDefaultDescription
variant
enum (default | success | warning | destructive)
defaultVisual style of the banner message.
dismissible
boolean
falseWhether the banner can be dismissed by the user.
open
boolean
-The controlled open state of the banner.
defaultOpen
boolean
trueThe default open state of the banner when uncontrolled.

Events

PropTypeDefaultDescription
onOpenChange
event
-Event handler called when the banner open state changes.
onClose
event
-Callback fired when the banner is dismissed.

Slots

PropTypeDefaultDescription
default
slot
-The banner segments

Parts

PropTypeDefaultDescription
root*
root
-The banner container
content
part
-The content wrapper
icon
part
-The icon section
title
part
-The banner title
description
part
-The banner description
actions
part
-The actions section
This API reference is generated from `/packages/core` component schemas to keep React/Vue/Weapp docs consistent.

该组件尚无扩展说明文档。

键盘与焦点

Keyboard

跨 React、Vue 与小程序共享的交互与可读名称约定。

  • Enter or Space on the close button named Close dismisses the banner.
  • The close button is in the tab order.
  • A banner that is not dismissible ignores that button.
  • The banner is a status.
  • The icon is hidden from that status.
  • In static HTML, Update and the close control are type button.
  • The close control is named Close and the mark is hidden from that name.
  • On the mini program, the close mark is hidden from the name.

行为契约

Contract

props、默认值和运行时状态。

  • The banner starts open unless defaultOpen is false.
  • Closing reports the open change.
  • The close control is a button named Close and is in the tab order.