June 27th, 2024

Flow Charts with CSS Anchor Positioning

The article explains using CSS Anchor Positioning to create flow charts and diagrams. It covers positioning elements, creating nodes with CSS tricks, expanding charts, and making nodes draggable with JavaScript. It aims to assist developers in creating interactive charts.

Read original articleLink Icon
Flow Charts with CSS Anchor Positioning

The article discusses the use of CSS Anchor Positioning to create flow charts and diagrams using CSS. It explains how to position elements relative to each other using anchor names and the anchor positioning properties. The post demonstrates basic positioning, multiple anchors, and creating flow chart nodes with CSS tricks like background gradients and pseudo elements for arrow heads. It also touches on expanding the flow chart with additional nodes and handling line directions based on node positions. The article concludes by mentioning the possibility of making the node elements draggable with JavaScript to create a draggable flow chart. Additionally, it provides related posts on topics like dynamic contrast layers, CSS container queries, and CSS interaction theming. The content aims to help developers understand and implement CSS Anchor Positioning for creating interactive and visually appealing flow charts and diagrams on the web.

Related

SVG: The Good, the Bad, and the Ugly (2021)

SVG: The Good, the Bad, and the Ugly (2021)

SVG, scalable vector graphics, is a versatile format for web design, supporting various graphic elements like paths, shapes, text, and animations. Despite its power, its complexity and extensive specifications can be challenging for users.

Exposition of Front End Build Systems

Exposition of Front End Build Systems

Frontend build systems are crucial in web development, involving transpilation, bundling, and minification steps. Tools like Babel and Webpack optimize code for performance and developer experience. Various bundlers like Webpack, Rollup, Parcel, esbuild, and Turbopack are compared for features and performance.

Microfeatures I love in blogs and personal websites

Microfeatures I love in blogs and personal websites

The article explores microfeatures for blogs and websites inspired by programming concepts. It highlights sidenotes, navigation tools, progress indicators, and interactive elements to improve user experience subtly. Examples demonstrate practical implementations.

Show HN: I built a large JavaScript powered flipdisc display. Here's a guide

Show HN: I built a large JavaScript powered flipdisc display. Here's a guide

Flipdisc displays, or flip dots, use electromagnetic pulses to switch colors. A project details building a large interactive display for offices, covering construction, power, software, and design considerations. It aims to explore real-time visualizations and user interactions, hoping to make flipdisc technology more accessible.

A New Package for Making Charts in Emacs: Eplot

A New Package for Making Charts in Emacs: Eplot

A new package named eplot simplifies chart creation in Emacs, addressing limitations of existing tools. It emphasizes clear axes markings and offers interactive data manipulation, introducing efficient plot control through "headers." Despite being a work in progress, eplot is accessible on Microsoft Github for potential use, with plans for code enhancements.

Link Icon 13 comments
By @dgb23 - 5 months
Neat examples!

However I think I would still use SVG for these sorts of things, especially since they can easily be manipulated, animated and are more mathematically declarative than CSS anchor positioning.

I think the sweet spot for this CSS feature is not having to do complex workarounds with calc, positioning, transforms or JS in order to have more control over positioning elements relative to others. Container queries have a similar use case.

Both of these features (as well as CSS grid) are born out of the same underlying issues:

- HTML and CSS are not orthogonal in terms of layout, but very tightly coupled

- Trees are a fundamentally crippled data structure to express layouts. Almost every sufficiently complex layout wants to be represented as a graph or a matrix. Trees are fine until they aren't.

By @bugfactory - 5 months
I'm constantly amazed by how much can be achieved with only CSS nowadays. It seems like it's getting more powerful by the month as developers find new and tricky ways to push the boundary ;)
By @ericyd - 5 months
Friendly warning that anchor positioning is not yet available in any non-Chromium-derived browser.
By @xnx - 5 months
We might have pushed CSS further than it should go, but using gradient for the connector lines is pretty clever.
By @lenkite - 5 months
Ideally, browsers should offer an API where a certain rect on screen can be rendered as SVG or PNG. Then such CSS flowcharts can be distributed as independent images instead of being a web-page.
By @simple10 - 5 months
Thanks for sharing. This has a lot of promise once browsers fully support anchor positioning. With the current rate of CSS standards adoption, my guess is Firefox and Safari will add support by end of this year. Pure speculation as they haven't announce support plans yet AFAIK.

Chrome and Edge currently support anchor positioning: https://caniuse.com/?search=css-anchor-positioning

By @autoexec - 5 months
Considering this is a CSS trick, it'd be nice if all the demos didn't require/load a ton of JS. Viewing source on the demos shows them to be like 90% javascript, several tens of thousands of characters, and that doesn't even include the five external JS files it also loads.
By @sollniss - 5 months
Connector lines not showing in Firefox.
By @AstroJetson - 5 months
I just use Markdeep and create the block diagrams that way

https://casual-effects.com/markdeep/features.md.html#diagram...

By @mediumsmart - 5 months
div popover in css … yay
By @meindnoch - 5 months
Great. Yet another special case added to CSS.
By @the_other - 5 months
Flow charts are a terrible use case for CSS (and HTML). The nodes and edges of a flow chart are all meaningful data. When you render the connectors using a mixture of empty divs, pseudo-content and largely arbitrary hacks, all that meaning gets lost from the _content_ (the HTML). Access tooling will largely fail to communicate your intent.

Flow charts are much better represented by something like PlantUML or Mermaid, and then rendered direct to SVG or a canvas. The mark-up is much more human-readable and could be used as source to drive an even-more accessible alternative.

By @gavinbao - 5 months
Is it possible that it can create a flow chart library with pure css? maybe like we make the className like tailwind to let others use to easily ship flow chat with pure css?