# Get calling cell name in called function

**URL:** https://talk.observablehq.com/t/get-calling-cell-name-in-called-function/3388
**Category:** Help
**Created:** [June 1, 2020, 10:13pm UTC](https://talk.observablehq.com/t/get-calling-cell-name-in-called-function/3388 "2020-06-01T22:13:33Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![dralletje](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/dralletje/32/2712_2.png) [@dralletje](https://talk.observablehq.com/u/dralletje)
#### Post date: [June 1, 2020, 10:13pm UTC](https://talk.observablehq.com/t/get-calling-cell-name-in-called-function/3388/1 "2020-06-01T22:13:33Z")

</div>

Is there a way to get a “callings cell”'s name?  
I am looking for a keyword or variable that will resolve to the name of the cell that a function is being called from:

```auto
Age = slider({ value: 10, min: 0, max: 120 }) // Slider can now show `"Age"` as title

slider = ({
  title = CELL_NAME, // or `import.meta.cell_name` or something
  ...options,
}) => {
  // Render slider with `title`
}

```

It seems like this is not yet possible. I do get why, as it is quite tricky (if not impossible) to make it work reliable. I think it would make experimenting with different inputs a lot easier, however. I now use a custom stylesheet to show a cells name to the left, because I just want to do `Age = slider({ value: 10, min: 0, max: 120 })` and not have to worry about showing the title.

Also it is useful for the sub-notebooks I’m using now, as repeating the cell name with room for error feels wasteful (Example: [Sub-notebook example: Debate Round Scheduler / Matcher / Michiel Dral / Observable](https://observablehq.com/@dralletje/sub-notebook-example-debate-round-scheduler-matcher#round_by_naive_search))

I made some examples for how to carry the name through functions calls using the Error stack, though this requires wrapping it explicitly, which is obviously even worse when not integrated into Observable:

> **[Cell name?](https://observablehq.com/@dralletje/cell-name)**
>
> I'm on a mission to get cell names in the contexts of the functions being called. For now I settled on using the Error stacktrace, which feels really hacky. Also getting the name in the Error stacktrace is actually pretty hacky. Test cases overview...

Is there a way I am missing that is currently available, or something more fundamental that makes it incompatible? Would love to see what comes up 🙂

---

<div class="post-metadata">

### Author: ![mootari](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mootari/32/581_2.png) [@mootari](https://talk.observablehq.com/u/mootari)
#### Post date: [June 2, 2020, 6:28pm UTC](https://talk.observablehq.com/t/get-calling-cell-name-in-called-function/3388/2 "2020-06-02T18:28:41Z")

</div>

No, that’s not possible. However, if you’re only interested in speeding up your prototyping workflow, you can create a user style to display each cell’s name:

> [@Fresh & clean new cell name display](https://talk.observablehq.com/t/fresh-clean-new-cell-name-display/1456/8):
>
> Me too, so I wrote a short user style to bring them back: @-moz-document domain("beta.observablehq.com") { div[id][data-node-id]:before { content: attr(id); position: absolute; right: calc(100% + 20px); top: 5px; pointer-events: none; z-index: 1; } } Screenshot: [user-style]

In its early days Observable would display each cell name in the editor UI (similar to what the above user CSS does). Many older notebooks include only unlabeled inputs because they relied on that feature.

---

<div class="post-metadata">

### Author: ![dralletje](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/dralletje/32/2712_2.png) [@dralletje](https://talk.observablehq.com/u/dralletje)
#### Post date: [June 3, 2020, 3:54pm UTC](https://talk.observablehq.com/t/get-calling-cell-name-in-called-function/3388/3 "2020-06-03T15:54:29Z")

</div>

Yeah, I have that now. Though it just doesn’t compare to having `cell_name =` in the result view ☹
