Skip to content

Block API: Choose a Block-Style for a Block Variation #21292

Closed

Description

@goaround

Is your feature request related to a problem? Please describe.
I would like to choose a different style for my variations. With the current API the that is not possible.

Describe the solution you'd like
A parameter like style: 'fancy' would be awesome: https://github.com/WordPress/gutenberg/blob/master/docs/designers-developers/developers/block-api/block-registration.md#variations-optional

Activity

  1. changed the title [-]Block API: Choose a Block-Style for a Block Variations [/-] [+]Block API: Choose a Block-Style for a Block Variation[/+] on Mar 31, 2020
  2. gziolo commented on Mar 31, 2020

    @gziolo
    Member

    You can do it by setting explicitly className attribute to the class name that the given style uses in the produced content. I’m aware that it isn’t the best way to achieve it so I agree that we should find a better way. I think your proposal sounds reasonable. We properly should use the name styleVariation to distinguish it from the style you define on the server for the block.

  3. added
    [Feature] Block API
    [Feature] Extensibility
    [Type] Enhancement
    Needs Dev
    on Mar 31, 2020
  4. gziolo commented on Mar 31, 2020

    @gziolo
    Member

    @mcsf or @youknowriad any thoughts on this proposal?

  5. youknowriad commented on Apr 1, 2020

    @youknowriad
    Contributor

    Personally, I feel using the className is a very reasonable way of doing this.

  6. mcsf commented on Apr 1, 2020

    @mcsf
    Contributor

    I think using className is acceptable too, mainly for two reasons:

    • Style variations are already an arguably low-level API, since they are just a wrapper for custom classes. For something more robust, proper Variations may be a better choice.
    • With the planned work in Global Styles, I'd rather not overload the term (and property name) style, since that may soon come to mean much more than just custom classes.
  7. goaround commented on Apr 1, 2020

    @goaround
    Author

    @gziolo the className attribute works for me. Thanks for pointing it out to me. Properly it would be good to add this to the documentation?

  8. added
    Needs Decision
    and removed
    Needs Dev
    on Apr 1, 2020
  9. added
    [Type] Developer Documentation
    and removed
    Needs Decision
    [Type] Enhancement
    on Apr 26, 2020
  10. self-assigned this
    on Apr 27, 2020
  11. added
    [Status] In Progress
    on Apr 27, 2020
  12. gziolo commented on Apr 27, 2020

    @gziolo
    Member

    I opened #21927 where I added an example. I hope it will help other folks 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

[Feature] Block API[Feature] Extensibility[Status] In Progress[Type] Developer Documentation

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions