/carbon-go

carbon design implementation in pure go: great with htmx

Primary LanguageCSSApache License 2.0Apache-2.0

carbon-go

https://carbon-go.io

every component implements the carbon.Component interface:

type Component interface {
	Render(w io.Writer)
	Attr(name, value string) Component
}

so, you can use it to write to anything that implements io.Writer. use in a server like this:

type foo struct {}

func (f *foo) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	carbon.Button("Hello world!").Render(w)
}

put HTMX tags on your component like this:

carbon.Button("Hello world!").Attr("hx-get", "https://example.com").Attr("hx-swap", "outerHTML").Render(w)

currently documentation sucks. just look at the docs for carbon design svelte. i've tried to keep it as similar as possible. moving forward, we should try to keep upstream with the react version when possible. i just didn't want to comb through react code.

will be adding doc comments.

TODO:

  • implement the rest of the components (copy button, textarea, etc...)
  • implement client side javascript for a few components
  • import icons on the fly and cache them server side instead of hardcoding them
  • automated testing against the react implemention to ensure markup generation parity
  • make every single component respect class Addr