每当我尝试将进度条放置在组/堆栈中时,它不会显示在网页上。只有当我将它放置在组/堆栈之外时,它才能工作。以下是代码和结果:
import { Stack, ThemeIcon, Text, Progress, Group, Button } from "@mantine/core";
interface SkillProps {
name: string;
icon: JSX.Element;
}
function Skill(props: SkillProps) {
return (
<>
<Group>
<ThemeIcon size={50} radius={25} variant="outline">
{props.icon}
</ThemeIcon>
<Stack align="center" spacing={5}>
<Text>{props.name}</Text>
</Stack>
<Progress value={50} />
</Group>
</>
);
}
export default Skill;
1条答案
按热度按时间7fhtutme1#
这可能是因为
Progress
在Group
或Stack
中时没有指定的父容器宽度。要在
Group
中使用,请尝试使用sx
prop将flex:"1"
添加到Progress
,这将占用Group
中的剩余空间:要在
Stack
中使用,请尝试添加alignSelf: "stretch"
以获得类似结果: