Replies: 5 comments 2 replies
|
Yes, In the registry source, "relative -my-2 h-5 text-sm ..."and then puts the actual <Separator className="absolute inset-0 top-1/2" />The So for your questions:
For a plain thin line with no label, I would either use <FieldSeparator className="my-0 h-px" />If you use the override, test it inside your exact If this explains the |
|
the h-5 is there because FieldSeparator was designed to handle both cases, a plain divider line and a divider with a text label in the middle. when you pass children (like "or" text between two fields), the wrapper needs enough vertical space so the text can sit centered over the line, and the background color trick on the span can visually "cut" through the separator. the 20px gives room for that text plus the negative margins that keep spacing consistent inside FieldGroup. when you use it without children though, that extra height just makes the gap look too thick even though the actual line is still 1px. the component doesnt distinguish between these two modes internally, it always reserves the label space. the reason there is no built in prop for this is because the component is relatively new and was shipped with the label use case as the primary design. a variant prop or a boolean like compact that drops the wrapper to h-px and removes the negative margins would make sense, but it just doesnt exist yet. for now if you want a thin line without touching className, using a plain Separator component directly inside FieldGroup works. it renders as 1px and the FieldGroup spacing still applies to it since it just treats it as another child element. FieldSeparator is really only needed when you want that centered text label cutting through the line. |
|
Yes, the h-5 (20px / 1.25rem) height is intended by design to accommodate the centered label overlay (children) when text like "OR" is passed inside the separator. Here is a breakdown of how the layout works and how to use it cleanly: 1. Why h-5 is thereWhen you pass children: 2. If you do NOT have children (plain divider line)If you only need a thin divider line between fields without text:
Passing className="h-px" is completely valid and will not break the component structure if no children are rendered! |
|
h-5 is the height of the FieldSeparator wrapper, not the thickness of the separator itself. In the current implementation, the actual Separator is positioned absolutely: So the h-5 is mainly providing a 20px-high layout area in which the separator is vertically centered. The -my-2 then offsets that space so it doesn't simply add 20px of visible spacing between the fields. This also makes sense when FieldSeparator has children: OR The child is placed in the middle of the separator with a background and horizontal padding, so the component needs a layout area larger than the 1px separator line itself. You don't need to pass orientation to the inner Separator for the normal horizontal use case. The component is already composing the separator for you, and the official examples use: directly between Field components. If you only want a simple 1px line with no content, overriding the wrapper's height can work, but I'd be careful with h-px because that changes the layout assumptions of the component, especially with the negative vertical margin. So I wouldn't consider h-5 itself evidence of a bug. It's more accurate to think of it as the separator's layout/label area, while the actual visible line remains a thin Separator. |
|
The thick line happens because of this line in the source: <Separator className="absolute inset-0 top-1/2" />In Tailwind, You can fix this cleanly in your component by changing <Separator className="absolute inset-x-0 top-1/2 -translate-y-1/2" />
|
Uh oh!
There was an error while loading. Please reload this page.
Component:
field.tsx>FieldSeparatorIssue Description
I'm using the
FieldSeparatorcomponent from shadcn's form fields, and I'm noticing it renders with a thick separator line by default. Looking at the source code, I see it hash-5set, which seems quite tall for a simple separator line.Here's the component code:
How I'm using it:
Screenshot:
Questions:
Is
h-5(20px) the intended height for this component? It seems visually large for a separator, but I want to confirm before overriding.Am I using this incorrectly? Am I missing any context or wrapper that would change how this renders?
Should I be passing something to
Separator(like orientation, className) to control its appearance?Is this designed to accommodate the
childrenprop (text/content inside the separator) in all cases, which is why it needs the extra height?What I've tried:
className="h-px"or similar to reduce the heightEnvironment:
Any guidance from the community or maintainers would be appreciated! 🙏
All reactions