Skip to content

Consider changing Card default Width from Size.Full() to Size.Fraction(1) #2687

Description

@nielsbosma

Problem

Card defaults to Width = Size.Full() (100% width) in its constructor (src/Ivy/Widgets/Card.cs:27). When multiple Cards are placed inside Layout.Horizontal(), they each take 100% width and stack vertically instead of appearing side-by-side.

This is a common pitfall — agents and new users frequently place Cards in horizontal layouts and get unexpected stacking behavior.

Screenshots

See session 55e7f454-675e-4e7f-b29e-e93134530200 for visual evidence.

Possible Solutions

  1. Change default to Size.Fraction(1) — Cards in horizontal layouts would share space equally by default. This better matches flex-item behavior but is a breaking change for any layout relying on Cards being full-width by default.

  2. Keep current default, improve docs — Add FAQ entries explaining the workaround (Width(Size.Fraction(1))). Already done in StackLayout docs.

  3. Context-aware default — Card could detect its parent layout orientation and adjust, but this adds complexity.

Questions for Review

  • Is Size.Full() the right default for Card, given that horizontal layouts are a common use case?
  • Would changing to Size.Fraction(1) cause significant breakage?
  • Should other widgets with Size.Full() defaults be reviewed similarly?

Metadata

Metadata

Assignees

No one assigned

    Labels

    API review requiredNeeds its API reviewed.bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions