Skip to content

Conversation

@ldez
Copy link
Contributor

@ldez ldez commented Sep 11, 2025

This is a draft to discuss the idea.

I created a button shortcode/partial (based on the hextra/button shortcode).
One of the goals is to "remove" hextra/button shortcode.

I also created a test page with buttons for the demo.

I have several questions:

  • The colors: I reused the colors from the badges, but I'm not sure about that; maybe more contrasted colors are better.
  • The content: I used the .Inner content because it allows complete customization, but it's more complex than simple shortcode parameters.

About the content, there are some complexities in aligning icons and text.
I added a CSS class to align the text and icons, but it requires the text to be wrapped in a <span> tag.

WDYT?

Demo: https://deploy-preview-830--hugo-hextra.netlify.app/docs/guide/shortcodes/button/

@netlify
Copy link

netlify bot commented Sep 11, 2025

Deploy Preview for hugo-hextra ready!

Name Link
🔨 Latest commit 64cd023
🔍 Latest deploy log https://app.netlify.com/projects/hugo-hextra/deploys/68c8a82a904486000841caeb
😎 Deploy Preview https://deploy-preview-830--hugo-hextra.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@imfing
Copy link
Owner

imfing commented Sep 11, 2025

Yeah, I definitely think this would be a great feature to add, I’ve been considering it for a while.

For inspiration:

Ideally, the button should be fairly generic, and the shortcode could expose options for things like variants, icons, etc.

@ldez
Copy link
Contributor Author

ldez commented Sep 11, 2025

Ideally, the button should be fairly generic, and the shortcode could expose options for things like variants, icons, etc.

I already handled:

  • size
  • colors
  • border and border size

With your sentence, I could understand that you prefer:

{{< button text="This is a button" icon-left="github" icon-right="arrow-circle-right" >}}

instead of

{{< button>}}
{{< icon name="github">}} This is a button {{< icon name="arrow-circle-right" >}}
{{< /button >}}

If my understanding is correct, I will follow this way (it's easier to fix some problems with this approach)

@ldez
Copy link
Contributor Author

ldez commented Sep 11, 2025

I used the same colors and button style (default, pills) as Flowbite.

@ldez
Copy link
Contributor Author

ldez commented Sep 11, 2025

I need explicit confirmation about the design of the component.

#830 (comment)

@imfing
Copy link
Owner

imfing commented Sep 11, 2025

I'm thinking something like:

{{< button size="small" color="primary" icon="github" iconPosition="start" >}}
We can put text here
{{< /button >}}

The iconPosition param ("start" | "end") would make it easier to control layout.
Without it, the inner icon placement can get tricky, for example:

{{< button >}} This is {{< icon foo >}} Button {{< /button >}}

That would render like this:

image

If no inner text is provided, the button can fall back to an icon-only style whenever the icon param is set:

{{< button size="large" color="primary" icon="github" >}}{{< /button >}}
image

what do you think?

@ldez
Copy link
Contributor Author

ldez commented Sep 11, 2025

Seems right, I will do that 👍

@imfing
Copy link
Owner

imfing commented Sep 11, 2025

The colors: I reused the colors from the badges, but I'm not sure about that; maybe more contrasted colors are better.

It’s fine for now. In the future if it makes sense, we can move these color into a theme-wide palette CSS variables https://tailwindcss.com/docs/theme#using-a-custom-theme so reusing them will be much easier.

@ldez
Copy link
Contributor Author

ldez commented Sep 11, 2025

@ldez
Copy link
Contributor Author

ldez commented Sep 12, 2025

I changed the design:

{{< button size="md" border="auto" mode="clear" shape="pills" color="indigo" icon="arrow-circle-right" iconPosition="end" >}}
This is a button
{{< /button >}}

options:

  • size: sm, md, lg, xl
  • color: primary, gray, purple, indigo, green, yellow, orange, amber, red
  • border: none, auto, sm, md, lg, xl
  • shape: default, pills
  • mode: default, clear
  • icon: name of the icon
  • iconPosition: start, end

Check the demo page https://deploy-preview-830--hugo-hextra.netlify.app/docs/guide/shortcodes/button/

@imfing
Copy link
Owner

imfing commented Sep 13, 2025

I changed the design:

{{< button size="md" border="auto" mode="clear" shape="pills" color="indigo" icon="arrow-circle-right" iconPosition="end" >}}
This is a button
{{< /button >}}

options:

  • size: sm, md, lg, xl
  • color: primary, gray, purple, indigo, green, yellow, orange, amber, red
  • border: none, auto, sm, md, lg, xl
  • shape: default, pills
  • mode: default, clear
  • icon: name of the icon
  • iconPosition: start, end

Check the demo page https://deploy-preview-830--hugo-hextra.netlify.app/docs/guide/shortcodes/button/

This looks amazing at first glance.

Could you please clarify the default values for the size, border, and iconPosition options?

I'm slightly confused about the auto value for the border. What CSS does that map to?

@ldez
Copy link
Contributor Author

ldez commented Sep 13, 2025

Option default Values
size md sm, md, lg, xl
color primary primary, gray, purple, indigo, green, yellow, orange, amber, red
border none none, auto, sm, md, lg, xl
shape default default, pills
mode default default, clear
icon - name of the icon
iconPosition start start, end

By default, there is no border. auto adds a border depending on the size of the button.

@ldez ldez changed the title feat(shotcode): add buttons Sep 15, 2025
@imfing
Copy link
Owner

imfing commented Oct 4, 2025

I'll make some minor updates to the interface and styling to better align with the theme’s look and feel

@ldez
Copy link
Contributor Author

ldez commented Oct 4, 2025

Remember, this is a draft; I was still waiting for feedback.

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

Labels

None yet

2 participants