Skip to content

How do I shrink width/height to fit content? #9424

Closed Answered by ickshonpe
mamekoro asked this question in Q&A
Discussion options

You must be logged in to vote

The default behaviour is AlignItems::Stretch which stretches the node to fill the whole cross-axis.
You can either use AlignSelf on the node, or AlignItems on its parent to change it:

fn spawn_dialog(commands: &mut Commands) -> Entity {
    commands
        .spawn(TextBundle {
            text: Text::from_sections([
                TextSection::new(
                    "Alex:\n",
                    TextStyle {
                        font_size: 30.0,
                        ..default()
                    },
                ),
                TextSection::new(
                    "Hi there.",
                    TextStyle {
                        font_size: 30.0,
                       …

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@mamekoro
Comment options

@atornity
Comment options

@mamekoro
Comment options

@atornity
Comment options

Answer selected by mamekoro
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants