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.
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>
)
}
用法
¥Usage
import { Blockquote } from "@chakra-ui/react"
<Blockquote.Root>
<Blockquote.Content cite="https://" />
<Blockquote.Caption>
<cite>Uzumaki Naruto</cite>
</Blockquote.Caption>
</Blockquote.Root>
如果你更喜欢封闭的组件组合,请查看 以下代码片段。
¥If you prefer a closed component composition, check out the snippet below.
示例
¥Examples
包含引用
¥With Cite
要提供有关区块引用的参考:
¥To provide reference about the blockquote:
-
将
cite
prop 传递给指向引用 URL 的Blockquote.Content
-
渲染
Blockquote.Caption
组件以显示引用作者的名称
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.
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>
)
}
颜色
¥Colors
使用 colorPalette
属性更改引用块的颜色。
¥Use the colorPalette
prop to change the color of the blockquote.
gray
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.
red
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.
green
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.
blue
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.
teal
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.
pink
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.
purple
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.
cyan
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.
orange
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.
yellow
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.
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>
)
}
变量
¥Variants
使用 variant
属性更改块引用的视觉样式。
¥Use the variant
prop to change the visual style of the blockquote.
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.
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.
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>
)
}
图标
¥Icon
以下是如何组合 Float
和 BlockquoteIcon
组件以在区块引用上显示图标的示例。默认图标为双引号。
¥Here's an example of how to compose the Float
and BlockquoteIcon
to show an
icon on the blockquote. The default icon is a double quote.
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.
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>
)
}
或者,你可以渲染自定义图标。
¥Alternatively, you can render a custom icon.
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.
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
使用 justify
属性更改块引用的对齐方式。
¥Use the justify
prop to change the alignment of the blockquote.
start
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.
center
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.
end
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.
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>
)
}
包含头像
¥With Avatar
以下示例展示了如何组合 Blockquote
、Avatar
和 Float
组件,以创建令人惊叹的用户评价组件。
¥Here's an example of how to compose the Blockquote
, Avatar
and Float
components to create a stunning testimonial component.
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.
import { 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>
)
}
已关闭组件
¥Closed Component
以下示例展示了如何创建封闭式组件组合。
¥Here's an example of how to create a closed component composition
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
如果你想自动将封闭式组件添加到项目中,请运行以下命令:
¥If you want to automatically add the closed component to your project, run the command:
npx @chakra-ui/cli snippet add blockquote
属性
¥Props
根元素
¥Root
Prop | Default | Type |
---|---|---|
colorPalette | 'gray' | 'gray' | 'red' | 'orange' | 'yellow' | 'green' | 'teal' | 'blue' | 'cyan' | 'purple' | 'pink' The color palette of the component |
justify | 'start' | 'start' | 'center' | 'end' The justify of the component |
variant | 'subtle' | 'subtle' | 'solid' | 'plain' The variant of the component |
as | React.ElementType The underlying element to render. | |
asChild | boolean Use the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. | |
unstyled | boolean Whether to remove the component's style. |