Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add name to a Bond #325

Closed
dpsanders opened this issue Aug 29, 2020 · 9 comments
Closed

Add name to a Bond #325

dpsanders opened this issue Aug 29, 2020 · 9 comments
Labels
enhancement New feature or request frontend Concerning the HTML editor

Comments

@dpsanders
Copy link

Now we have the possibility of having the value next to a slider -- great!
It would be useful to have the name of the variable too.

@fonsp fonsp changed the title Add name to a slider Add name to a Bond Aug 30, 2020
@fonsp
Copy link
Owner

fonsp commented Aug 30, 2020

Yeah that's cool

@fonsp fonsp added enhancement New feature or request frontend Concerning the HTML editor labels Sep 2, 2020
@stillyslalom
Copy link

Maybe just a label field? I've been working around this with

begin
	var_slider = @bind var Slider(LinRange(0, 20, 1001), default=10)
	md"""
	A descriptive label for `var` $var_slider
	"""
end

image

@fonsp
Copy link
Owner

fonsp commented Sep 2, 2020

What do you mean?

@stillyslalom
Copy link

@bind var <binding> label="A descriptive label for `var`"

@fonsp
Copy link
Owner

fonsp commented Sep 2, 2020

Aha, for that you can use:

md"A descriptive label for `var` $(@bind var Slider(LinRange(0, 20, 1001), default=10))"

@stillyslalom
Copy link

I understand not wanting to add too much clutter to the @bind interface, but label is a common HTML tag with universal browser support; it also helps accessibility for screen readers.

@fonsp
Copy link
Owner

fonsp commented Sep 3, 2020

Ah now I get it

@fonsp
Copy link
Owner

fonsp commented May 19, 2022

You can use this:

# ╔═╡ 3027890b-196b-4a65-9f17-0180d21f6beb
using HypertextLiteral

# ╔═╡ 19da2136-a5e4-476e-95a9-853960e3a50f
macro label_bind(name::Symbol, ex::Expr)
    quote
        @htl("""
        <div style='display: flex;'>
        <code style='font-weight: bold'>$($(String(name)))</code>: $(@bind $(name) $(esc(ex)))
        </div>
        """)
    end
end

image-1652964737328

@Pangoraw
Copy link
Collaborator

Pangoraw commented Sep 9, 2024

Now that there is JuliaPluto/PlutoUI.jl#305, i am closing this. Feel free to reopen

@Pangoraw Pangoraw closed this as completed Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request frontend Concerning the HTML editor
Projects
None yet
Development

No branches or pull requests

4 participants