Form ignores Styled refinements such as gap_5()

Author: 0x1f57Created Sep 16, 2026Updated Sep 16, 2026

Description

Form implements Styled and stores style refinements in its style field, but Form::render never applies self.style to the rendered element. As a result, style helpers called directly on v_form()/h_form(), such as .gap_5(), .p_5(), and .bg(...), are silently ignored.

This affects gpui-component 0.6.1 and is also present on the current main branch:

https://github.com/longbridge/gpui-kit/blob/main/crates/component/src/form/form.rs#L119-L150

Environment

  • GPUI (gpui-pre): v0.3.4
  • GPUI Component: v0.6.1
  • Platform: Windows 11, build 26100
  • Rust: 1.98.1

Steps to Reproduce

rust
v_form()
    .gap_5()
    .child(field().child(div().child("One")))
    .child(field().child(div().child("Two")))

Other Styled methods applied directly to Form, for example .p_5() or .bg(rgb(0xff0000)), are ignored as well.

Expected

The fields should have the spacing requested by .gap_5() (20 px with the default rem size), and other style refinements should be applied to the rendered form container.

Actual

The form keeps its built-in vertical gap (8 px for the default size), regardless of .gap_5(). Other externally supplied style refinements are also discarded.

Styled::style() writes into Form::style:

rust
impl Styled for Form {
    fn style(&mut self) -> &mut StyleRefinement {
        &mut self.style
    }
}

However, Form::render() builds and returns a new v_flex() without calling refine_style(&self.style). Other styled components, including Field, apply their stored refinement this way.

A possible fix is to apply the form refinement after its built-in layout defaults so caller-provided styles can override them:

rust
v_flex()
    // built-in form layout...
    .refine_style(&self.style)

Source: longbridge/gpui-component