如果有人自以为是,其实什么也不是,那就是欺骗自己。各人应当察验自己的行为,这样他所夸口的,只在于自己,不必与别人比较。
import { Blockquote } from "@chakra-ui/react"
const Demo = () => {
return (
<Blockquote.Root>
<Blockquote.Content>
If anyone thinks he is something when he is nothing, he deceives
himself. Each one should test his own actions. Then he can take pride in
himself, without comparing himself to anyone else.
</Blockquote.Content>
</Blockquote.Root>
)
}
用法
import { Blockquote } from "@chakra-ui/react"
<Blockquote.Root>
<Blockquote.Content cite="https://" />
<Blockquote.Caption>
<cite>Uzumaki Naruto</cite>
</Blockquote.Caption>
</Blockquote.Root>
信息
如果您更喜欢封闭式组件组合,请查看下方代码片段。示例
带引文
提供关于块引用的参考
- 将
cite
属性传递给Blockquote.Content
,指向引用网址 - 渲染
Blockquote.Caption
组件以显示引用作者的姓名
如果有人自以为是,其实什么也不是,那就是欺骗自己。各人应当察验自己的行为,这样他所夸口的,只在于自己,不必与别人比较。
import { Blockquote } from "@chakra-ui/react"
const Demo = () => {
return (
<Blockquote.Root>
<Blockquote.Content cite="Uzumaki Naruto">
If anyone thinks he is something when he is nothing, he deceives
himself. Each one should test his own actions. Then he can take pride in
himself, without comparing himself to anyone else.
</Blockquote.Content>
<Blockquote.Caption>
— <cite>Uzumaki Naruto</cite>
</Blockquote.Caption>
</Blockquote.Root>
)
}
颜色
使用 colorPalette
属性改变块引用的颜色。
灰色
如果有人自以为是,其实什么也不是,那就是欺骗自己。各人应当察验自己的行为,这样他所夸口的,只在于自己,不必与别人比较。
红色
如果有人自以为是,其实什么也不是,那就是欺骗自己。各人应当察验自己的行为,这样他所夸口的,只在于自己,不必与别人比较。
绿色
如果有人自以为是,其实什么也不是,那就是欺骗自己。各人应当察验自己的行为,这样他所夸口的,只在于自己,不必与别人比较。
蓝色
如果有人自以为是,其实什么也不是,那就是欺骗自己。各人应当察验自己的行为,这样他所夸口的,只在于自己,不必与别人比较。
水鸭色
如果有人自以为是,其实什么也不是,那就是欺骗自己。各人应当察验自己的行为,这样他所夸口的,只在于自己,不必与别人比较。
粉色
如果有人自以为是,其实什么也不是,那就是欺骗自己。各人应当察验自己的行为,这样他所夸口的,只在于自己,不必与别人比较。
紫色
如果有人自以为是,其实什么也不是,那就是欺骗自己。各人应当察验自己的行为,这样他所夸口的,只在于自己,不必与别人比较。
青色
如果有人自以为是,其实什么也不是,那就是欺骗自己。各人应当察验自己的行为,这样他所夸口的,只在于自己,不必与别人比较。
橙色
如果有人自以为是,其实什么也不是,那就是欺骗自己。各人应当察验自己的行为,这样他所夸口的,只在于自己,不必与别人比较。
黄色
如果有人自以为是,其实什么也不是,那就是欺骗自己。各人应当察验自己的行为,这样他所夸口的,只在于自己,不必与别人比较。
import { Blockquote, Stack, Text } from "@chakra-ui/react"
import { colorPalettes } from "compositions/lib/color-palettes"
const Demo = () => {
return (
<Stack gap="5" align="flex-start">
{colorPalettes.map((colorPalette) => (
<Stack
align="center"
key={colorPalette}
direction="row"
gap="10"
px="4"
width="full"
>
<Text minW="8ch">{colorPalette}</Text>
<Blockquote.Root colorPalette={colorPalette}>
<Blockquote.Content cite="Uzumaki Naruto">
If anyone thinks he is something when he is nothing, he deceives
himself. Each one should test his own actions. Then he can take
pride in himself, without comparing himself to anyone else.
</Blockquote.Content>
<Blockquote.Caption>
— <cite>Uzumaki Naruto</cite>
</Blockquote.Caption>
</Blockquote.Root>
</Stack>
))}
</Stack>
)
}
变体
使用 variant
属性改变块引用的视觉样式。
如果有人自以为是,其实什么也不是,那就是欺骗自己。各人应当察验自己的行为,这样他所夸口的,只在于自己,不必与别人比较。
如果有人自以为是,其实什么也不是,那就是欺骗自己。各人应当察验自己的行为,这样他所夸口的,只在于自己,不必与别人比较。
import { Blockquote, Stack } from "@chakra-ui/react"
const Demo = () => {
return (
<Stack gap="8">
<Blockquote.Root variant="subtle">
<Blockquote.Content>
If anyone thinks he is something when he is nothing, he deceives
himself. Each one should test his own actions. Then he can take pride
in himself, without comparing himself to anyone else.
</Blockquote.Content>
</Blockquote.Root>
<Blockquote.Root variant="solid">
<Blockquote.Content>
If anyone thinks he is something when he is nothing, he deceives
himself. Each one should test his own actions. Then he can take pride
in himself, without comparing himself to anyone else.
</Blockquote.Content>
</Blockquote.Root>
</Stack>
)
}
图标
这是一个如何组合 Float
和 BlockquoteIcon
以在块引用上显示图标的示例。默认图标是双引号。
如果有人自以为是,其实什么也不是,那就是欺骗自己。各人应当察验自己的行为,这样他所夸口的,只在于自己,不必与别人比较。
import { Blockquote, Float } from "@chakra-ui/react"
const Demo = () => {
return (
<Blockquote.Root variant="plain" colorPalette="teal">
<Float placement="top-start" offsetY="2">
<Blockquote.Icon />
</Float>
<Blockquote.Content cite="Uzumaki Naruto">
If anyone thinks he is something when he is nothing, he deceives
himself. Each one should test his own actions. Then he can take pride in
himself, without comparing himself to anyone else.
</Blockquote.Content>
<Blockquote.Caption>
— <cite>Uzumaki Naruto</cite>
</Blockquote.Caption>
</Blockquote.Root>
)
}
或者,您可以渲染一个自定义图标。
如果有人自以为是,其实什么也不是,那就是欺骗自己。各人应当察验自己的行为,这样他所夸口的,只在于自己,不必与别人比较。
import { Blockquote, Circle, Float } from "@chakra-ui/react"
import { LuQuote } from "react-icons/lu"
const Demo = () => {
return (
<Blockquote.Root colorPalette="blue" ps="8">
<Float placement="middle-start">
<Circle bg="blue.600" size="8" color="white">
<LuQuote />
</Circle>
</Float>
<Blockquote.Content cite="Uzumaki Naruto">
If anyone thinks he is something when he is nothing, he deceives
himself. Each one should test his own actions. Then he can take pride in
himself, without comparing himself to anyone else.
</Blockquote.Content>
<Blockquote.Caption>
— <cite>Uzumaki Naruto</cite>
</Blockquote.Caption>
</Blockquote.Root>
)
}
对齐
使用 justify
属性改变块引用的对齐方式。
起始
如果有人自以为是,其实什么也不是,那就是欺骗自己。各人应当察验自己的行为,这样他所夸口的,只在于自己,不必与别人比较。
居中
如果有人自以为是,其实什么也不是,那就是欺骗自己。各人应当察验自己的行为,这样他所夸口的,只在于自己,不必与别人比较。
结束
如果有人自以为是,其实什么也不是,那就是欺骗自己。各人应当察验自己的行为,这样他所夸口的,只在于自己,不必与别人比较。
import { Blockquote, For, HStack, Stack, Text } from "@chakra-ui/react"
const Demo = () => {
return (
<Stack gap="20">
<For each={["start", "center", "end"]}>
{(justify) => (
<HStack key={justify} maxW="xl">
<Text color="fg.muted" minW="6rem">
{justify}
</Text>
<Blockquote.Root variant="plain" justify={justify}>
<Blockquote.Content cite="Uzumaki Naruto">
If anyone thinks he is something when he is nothing, he deceives
himself. Each one should test his own actions. Then he can take
pride in himself, without comparing himself to anyone else.
</Blockquote.Content>
<Blockquote.Caption>
— <cite>Uzumaki Naruto</cite>
</Blockquote.Caption>
</Blockquote.Root>
</HStack>
)}
</For>
</Stack>
)
}
带头像
这是一个如何组合 Blockquote
、Avatar
和 Float
组件以创建令人惊叹的推荐组件的示例。
如果有人自以为是,其实什么也不是,那就是欺骗自己。各人应当察验自己的行为,这样他所夸口的,只在于自己,不必与别人比较。
EJ
Emily Jonesimport { Avatar, Blockquote, Float, HStack, Span } from "@chakra-ui/react"
const Demo = () => {
return (
<Blockquote.Root bg="bg.subtle" padding="8">
<Float placement="bottom-end" offset="10">
<Blockquote.Icon opacity="0.4" boxSize="10" rotate="180deg" />
</Float>
<Blockquote.Content cite="Uzumaki Naruto">
If anyone thinks he is something when he is nothing, he deceives
himself. Each one should test his own actions. Then he can take pride in
himself, without comparing himself to anyone else.
</Blockquote.Content>
<Blockquote.Caption>
<cite>
<HStack mt="2" gap="3">
<Avatar.Root size="sm">
<Avatar.Fallback name="Emily Jones" />
<Avatar.Image src="https://i.pravatar.cc/150?u=re" />
</Avatar.Root>
<Span fontWeight="medium">Emily Jones</Span>
</HStack>
</cite>
</Blockquote.Caption>
</Blockquote.Root>
)
}
封闭组件
这是一个如何创建封闭组件组合的示例
import { Blockquote as ChakraBlockquote } from "@chakra-ui/react"
import * as React from "react"
export interface BlockquoteProps extends ChakraBlockquote.RootProps {
cite?: React.ReactNode
citeUrl?: string
icon?: React.ReactNode
showDash?: boolean
}
export const Blockquote = React.forwardRef<HTMLDivElement, BlockquoteProps>(
function Blockquote(props, ref) {
const { children, cite, citeUrl, showDash, icon, ...rest } = props
return (
<ChakraBlockquote.Root ref={ref} {...rest}>
{icon}
<ChakraBlockquote.Content cite={citeUrl}>
{children}
</ChakraBlockquote.Content>
{cite && (
<ChakraBlockquote.Caption>
{showDash ? <>—</> : null} <cite>{cite}</cite>
</ChakraBlockquote.Caption>
)}
</ChakraBlockquote.Root>
)
},
)
export const BlockquoteIcon = ChakraBlockquote.Icon
如果您想自动将封闭组件添加到您的项目中,请运行以下命令
npx @chakra-ui/cli snippet add blockquote
属性
根
属性 | 默认值 | 类型 |
---|---|---|
colorPalette | '灰色' | '灰色' | '红色' | '橙色' | '黄色' | '绿色' | '水鸭色' | '蓝色' | '青色' | '紫色' | '粉色' 组件的配色方案 |
justify | '起始' | '起始' | '居中' | '结束' 组件的对齐方式 |
variant | '柔和' | '柔和' | '实色' | '普通' 组件的样式 |